SlideShare a Scribd company logo
The Use of Static Code Analysis When Teaching
or Developing Open-Source Software
Presenter:
George Gribkov
1. Static analysis: short overview
2. Use of static analysis at colleges and universities
3. Use of static analysis in student and open projects
Contents
2
Static Analysis: Short Overview
3
 Write correct code
 Unit tests
 Regression testing
 Code review
 …is there some other way?
 Yes! For example – tools for automated analysis.
How to Improve Code Quality
4
 Static analysis tools: check code when it’s not
executed
 Dynamic analysis tools: check code when it’s being
executed
Automated Code Analysis Tools
5
 Both approaches compliment each other very well.
Cost to Fix a Bug
6
 Issues false positives
 Difficulties with multithreading
 Does not eliminate the need for code review
Static Analysis Disadvantages
7
 Covers the entire code
 Significantly faster than dynamic code analysis
 More convenient for large projects
Static Analysis Advantages
8
 Can check code style or whether the code complies
with a coding standard (MISRA, AUTOSAR C++)
 Easy to use
 Helps developers learn and teach
Static Analysis Advantages
9
Use of Static Analysis at Colleges and
Universitites
10
 Helps check homework
 Helps check final projects
 Saves instructors’ time
For Instructors
11
 Provides a chance to learn a new approach
 Helps with self-study and problem solving
 Facilitates development
 Shows and helps study error patterns
For Students
12
Pattern Examples (Vangers)
13
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete p;
delete p1;
}
Pattern Examples (Vangers)
14
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete p; // <=
delete p1; // <=
}
Pattern Examples (Vangers)
15
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete [] p;
delete [] p1;
}
Pattern Examples (Apache HTTP Server)
16
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset(x, 0, sizeof(x));
}
Pattern Examples (Apache HTTP Server)
17
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset(x, 0, sizeof(x)); // <=
}
Pattern Examples (Apache HTTP Server)
18
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset_s(x, 0, sizeof(x));
}
*Or use the following flag: -fno-builtin-memset!
 Provides a chance to learn a new approach
 Helps with self-study and problem solving
 Facilitates development
 Shows and helps study error patterns
For Students
19
Use of Static Analysis in Student and
Open Projects
20
 Static analysis provides its maximum benefit
only when used regularly!
Regular Use is the Main Thing
21
Regular Use is the Main Thing
22
Efficient Static Analyzers
23
• PVS-Studio
• Clang Static Analyzer
• Cppcheck
• Infer
• IntelliJ IDEA
• FindBugs
• ...
• A detailed list of static
analyzers:
1. A classic development scenario
(in office)
2. Developing student and open-source projects
Introducing Analysis
24
 Locally on developers’ computer (plugins for IDE,
compilation monitoring system)
A Typical Scenario
25
 Continuous integration systems (command-line utilities,
plugins for CI systems, monitoring systems)
A Typical Scenario
26
A Typical Scenario
27
What’s the difference?
Student and Open-Source Projects
28
A Typical Scenario
29
Student and Open-Source Projects
30
Student and Open-Source Projects
31
Student and Open-Source Projects
32
Student and Open-Source Projects
33
Using an Analyzer on Open-Source Projects
34
Using an Analyzer on Open-Source Projects
35
How to Analyze Community Contribution?
36
What to Do After the First Check?
37
Using an Analyzer on Open-Source Projects
38
Using an Analyzer on Open-Source Projects
39
Pull Request Analysis
40
How to Analyze Community Contribution?
41
 Suppress bases are a mass suppression tool for
the analyzer’s warnings.
After the First Check
42
 Suppress bases are a mass suppression tool for
the analyzer’s warnings.
After the First Check
43
 Hide old errors – keep up the normal pace
 See only the latest warnings starting from this moment
 Get immediate benefits from the analyzer
 Do not forget about the old errors! Come back and fix them
one-by-one.
The Purpose of Suppress Bases
44
 A very convenient approach: the “ratcheting” method
 The number of errors in the base is committed to the repository.
 Changes are allowed only when they do not increase the total
number of errors.
How to Work with Suppress Base
45
How to Work with Suppress Base
46
 https://habr.com/en/post/440610/
An Article on the Topic
47
Conclusion
48
 Static analysis helps study programming
 It’s important to use static analysis regularly
 It’s okay to use static analysis in open-source projects!
Recap
49
A Free PVS-Studio License for Open-Source Project
Developers
50
END
Q&A51

More Related Content

PDF
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
PDF
TMPA-2017: Vellvm - Verifying the LLVM
PDF
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
PDF
TMPA-2015: A Need To Specify and Verify Standard Functions
PDF
Cppcheck
PPTX
Reverse Engineering automation
PDF
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
PPT
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
TMPA-2015: A Need To Specify and Verify Standard Functions
Cppcheck
Reverse Engineering automation
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems

What's hot (20)

PDF
Symbolic Execution (introduction and hands-on)
PPTX
Loops in c
PDF
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
PPT
Code Analysis-run time error prediction
PPTX
Static analysis
PDF
Search-driven String Constraint Solving for Vulnerability Detection
PDF
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
PPTX
IEEE SCAM 2017 Revisiting Exception Handling Practices with Exception Flow An...
PPT
Templates exception handling
PPT
9781285852744 ppt ch14
PPTX
Extending C# with Roslyn and Code Aware Libraries
PPT
Unit iii
PDF
Mock object
PDF
Java 8 - Lambdas and much more
PPTX
PPTX
C programming language tutorial
PPT
Storage classes
DOCX
Qtp certification questions2
PPTX
C language (Part 2)
PDF
Headache from using mathematical software
Symbolic Execution (introduction and hands-on)
Loops in c
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Code Analysis-run time error prediction
Static analysis
Search-driven String Constraint Solving for Vulnerability Detection
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
IEEE SCAM 2017 Revisiting Exception Handling Practices with Exception Flow An...
Templates exception handling
9781285852744 ppt ch14
Extending C# with Roslyn and Code Aware Libraries
Unit iii
Mock object
Java 8 - Lambdas and much more
C programming language tutorial
Storage classes
Qtp certification questions2
C language (Part 2)
Headache from using mathematical software
Ad

Similar to The Use of Static Code Analysis When Teaching or Developing Open-Source Software (20)

PPTX
Does static analysis need machine learning?
PPT
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
PPTX
The operation principles of PVS-Studio static code analyzer
PPTX
PVS-Studio and static code analysis technique
PDF
Reducing Redundancies in Multi-Revision Code Analysis
PPTX
Introduction to White box testing
PDF
Skiron - Experiments in CPU Design in D
PPTX
Static analysis works for mission-critical systems, why not yours?
PPTX
Code instrumentation
PDF
Fuzzing - Part 2
PDF
What’s eating python performance
PPT
01SoftwEng.pptInnovation technology pptInnovation technology ppt
PPTX
SE2023 0401 Software Coding and Testing.pptx
PPTX
Physics lab ppt for btech students in engineetin
PPTX
Static code analysis: what? how? why?
PDF
Online Machine Learning: introduction and examples
PPSX
Ds03 part i algorithms by jyoti lakhani
PPT
5.Black Box Testing and Levels of Testing.ppt
PDF
More about PHP
PPT
ch01-basic-java-programs.ppt
Does static analysis need machine learning?
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
The operation principles of PVS-Studio static code analyzer
PVS-Studio and static code analysis technique
Reducing Redundancies in Multi-Revision Code Analysis
Introduction to White box testing
Skiron - Experiments in CPU Design in D
Static analysis works for mission-critical systems, why not yours?
Code instrumentation
Fuzzing - Part 2
What’s eating python performance
01SoftwEng.pptInnovation technology pptInnovation technology ppt
SE2023 0401 Software Coding and Testing.pptx
Physics lab ppt for btech students in engineetin
Static code analysis: what? how? why?
Online Machine Learning: introduction and examples
Ds03 part i algorithms by jyoti lakhani
5.Black Box Testing and Levels of Testing.ppt
More about PHP
ch01-basic-java-programs.ppt
Ad

More from Andrey Karpov (20)

PDF
60 антипаттернов для С++ программиста
PDF
60 terrible tips for a C++ developer
PPTX
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
PDF
PVS-Studio in 2021 - Error Examples
PDF
PVS-Studio in 2021 - Feature Overview
PDF
PVS-Studio в 2021 - Примеры ошибок
PDF
PVS-Studio в 2021
PPTX
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
PPTX
Best Bugs from Games: Fellow Programmers' Mistakes
PPTX
Typical errors in code on the example of C++, C#, and Java
PPTX
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
PPTX
Game Engine Code Quality: Is Everything Really That Bad?
PPTX
C++ Code as Seen by a Hypercritical Reviewer
PPTX
Static Code Analysis for Projects, Built on Unreal Engine
PPTX
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
PPTX
The Great and Mighty C++
PDF
Zero, one, two, Freddy's coming for you
PDF
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PDF
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PDF
Analysis of commits and pull requests in Travis CI, Buddy and AppVeyor using ...
60 антипаттернов для С++ программиста
60 terrible tips for a C++ developer
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Feature Overview
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Best Bugs from Games: Fellow Programmers' Mistakes
Typical errors in code on the example of C++, C#, and Java
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
Game Engine Code Quality: Is Everything Really That Bad?
C++ Code as Seen by a Hypercritical Reviewer
Static Code Analysis for Projects, Built on Unreal Engine
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
The Great and Mighty C++
Zero, one, two, Freddy's coming for you
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
Analysis of commits and pull requests in Travis CI, Buddy and AppVeyor using ...

Recently uploaded (20)

PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
Pre independence Education in Inndia.pdf
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
How to Manage Starshipit in Odoo 18 - Odoo Slides
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
Open Quiz Monsoon Mind Game Final Set.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Final Stretch: How to Release a Game and Not Die in the Process.
Introduction and Scope of Bichemistry.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Module 3: Health Systems Tutorial Slides S2 2025
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Open Quiz Monsoon Mind Game Prelims.pptx
Cardiovascular Pharmacology for pharmacy students.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Open folder Downloads.pdf yes yes ges yes
Pre independence Education in Inndia.pdf
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)

The Use of Static Code Analysis When Teaching or Developing Open-Source Software

  • 1. The Use of Static Code Analysis When Teaching or Developing Open-Source Software Presenter: George Gribkov
  • 2. 1. Static analysis: short overview 2. Use of static analysis at colleges and universities 3. Use of static analysis in student and open projects Contents 2
  • 4.  Write correct code  Unit tests  Regression testing  Code review  …is there some other way?  Yes! For example – tools for automated analysis. How to Improve Code Quality 4
  • 5.  Static analysis tools: check code when it’s not executed  Dynamic analysis tools: check code when it’s being executed Automated Code Analysis Tools 5  Both approaches compliment each other very well.
  • 6. Cost to Fix a Bug 6
  • 7.  Issues false positives  Difficulties with multithreading  Does not eliminate the need for code review Static Analysis Disadvantages 7
  • 8.  Covers the entire code  Significantly faster than dynamic code analysis  More convenient for large projects Static Analysis Advantages 8
  • 9.  Can check code style or whether the code complies with a coding standard (MISRA, AUTOSAR C++)  Easy to use  Helps developers learn and teach Static Analysis Advantages 9
  • 10. Use of Static Analysis at Colleges and Universitites 10
  • 11.  Helps check homework  Helps check final projects  Saves instructors’ time For Instructors 11
  • 12.  Provides a chance to learn a new approach  Helps with self-study and problem solving  Facilitates development  Shows and helps study error patterns For Students 12
  • 13. Pattern Examples (Vangers) 13 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete p; delete p1; }
  • 14. Pattern Examples (Vangers) 14 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete p; // <= delete p1; // <= }
  • 15. Pattern Examples (Vangers) 15 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete [] p; delete [] p1; }
  • 16. Pattern Examples (Apache HTTP Server) 16 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset(x, 0, sizeof(x)); }
  • 17. Pattern Examples (Apache HTTP Server) 17 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset(x, 0, sizeof(x)); // <= }
  • 18. Pattern Examples (Apache HTTP Server) 18 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset_s(x, 0, sizeof(x)); } *Or use the following flag: -fno-builtin-memset!
  • 19.  Provides a chance to learn a new approach  Helps with self-study and problem solving  Facilitates development  Shows and helps study error patterns For Students 19
  • 20. Use of Static Analysis in Student and Open Projects 20
  • 21.  Static analysis provides its maximum benefit only when used regularly! Regular Use is the Main Thing 21
  • 22. Regular Use is the Main Thing 22
  • 23. Efficient Static Analyzers 23 • PVS-Studio • Clang Static Analyzer • Cppcheck • Infer • IntelliJ IDEA • FindBugs • ... • A detailed list of static analyzers:
  • 24. 1. A classic development scenario (in office) 2. Developing student and open-source projects Introducing Analysis 24
  • 25.  Locally on developers’ computer (plugins for IDE, compilation monitoring system) A Typical Scenario 25
  • 26.  Continuous integration systems (command-line utilities, plugins for CI systems, monitoring systems) A Typical Scenario 26
  • 28. What’s the difference? Student and Open-Source Projects 28
  • 30. Student and Open-Source Projects 30
  • 31. Student and Open-Source Projects 31
  • 32. Student and Open-Source Projects 32
  • 33. Student and Open-Source Projects 33
  • 34. Using an Analyzer on Open-Source Projects 34
  • 35. Using an Analyzer on Open-Source Projects 35
  • 36. How to Analyze Community Contribution? 36
  • 37. What to Do After the First Check? 37
  • 38. Using an Analyzer on Open-Source Projects 38
  • 39. Using an Analyzer on Open-Source Projects 39
  • 41. How to Analyze Community Contribution? 41
  • 42.  Suppress bases are a mass suppression tool for the analyzer’s warnings. After the First Check 42
  • 43.  Suppress bases are a mass suppression tool for the analyzer’s warnings. After the First Check 43
  • 44.  Hide old errors – keep up the normal pace  See only the latest warnings starting from this moment  Get immediate benefits from the analyzer  Do not forget about the old errors! Come back and fix them one-by-one. The Purpose of Suppress Bases 44
  • 45.  A very convenient approach: the “ratcheting” method  The number of errors in the base is committed to the repository.  Changes are allowed only when they do not increase the total number of errors. How to Work with Suppress Base 45
  • 46. How to Work with Suppress Base 46
  • 49.  Static analysis helps study programming  It’s important to use static analysis regularly  It’s okay to use static analysis in open-source projects! Recap 49
  • 50. A Free PVS-Studio License for Open-Source Project Developers 50