SlideShare a Scribd company logo
1 of 50
PVS-Studio Team
www.viva64.com
Static Code Analysis:
Keeping the Cost of Bug
Fixing Down
Bugs Have Always Been and Will Always
Be There
• No use preaching "careful coding"
• Bugs have always been and will always be there
• Everybody knows bugs should be fixed
• People forget that bugs should be fixed at the lowest cost possible in
terms of time and money!
Too Many Heroes Are a Bad Sign
• You may enjoy telling people how your team spent a week heroically
hunting for a bug
• But the fact that your team has to perform such feats does it no credit
This city code needs a hero!
The Sooner You Fix, the Better
• Depending on the bug pattern, fixing at the coding stage is 10–100
times cheaper than after the release
• Various techniques are available:
• code review
• unit testing (or TDD)
• testing a new feature by its author
• dynamic code analysis (a variation of testing)
• static analysis, which will be discussed further
What Code Review Is
• Code is examined by several programmers
• Ideally, they shouldn’t be using a computer
• They give their comments and
advice on what to fix and improve
Pros of Code Review by Humans
• You can find complex bugs
• You can find high-level defects (such as slow algorithms)
Cons of Code Review by Humans
• There could be bugs none of the reviewers is aware of
• It’s expensive
• Humans get tired fast
Static Analysis as a Compromise
• Pros of analyzers:
• they check the entire code
• they don’t get tired
• they can recognize tricky bug patterns
• Cons:
• they are just programs, not an AI
• They are definitely useful thanks to immediate detection of bugs
• Analogy: the spell check in Microsoft Word.
Static Analysis Tools
• We’ll take PVS-Studio as an example
• But there are many other tools to fit any taste:
• FxCop
• Klocwork
• Parasoft
• SonarQube
• Veracode
• More: https://en.Wikipedia.org/wiki/List_of_tools_for_static_code_analysis
A Few Examples: A Typo
static bool AreEqual (VisualStyleElement value1,
VisualStyleElement value2)
{
return
value1.ClassName == value1.ClassName &&
value1.Part == value2.Part &&
value1.State == value2.State;
}
PVS-Studio: V3001 There are identical sub-expressions 'value1.ClassName' to the left and to
the right of the '==' operator. ThemeVisualStyles.cs 2141
Mono
A Few Examples: Coding in a Hurry
void IBackgroundTask.Sweep()
{
....
// Don't flood the database with progress updates;
// Limit it to every 5 seconds.
if ((_clock.UtcNow - lastUpdateUtc).Seconds >= 5)
{
....
PVS-Studio: V3118 Seconds component of TimeSpan is used, which does not represent full
time interval. Possibly 'TotalSeconds' value was intended instead. AssetUploader.cs 182
Orchard CMS
should be
TotalSeconds
A Few Examples: Sorting
PVS-Studio: V3078 Original sorting order will be lost after repetitive call to 'OrderBy' method.
Use 'ThenBy' method to preserve the original sorting. CodeCoverageMethodElement.cs 124
SharpDevelop
void Init()
{
....
this.SequencePoints.OrderBy(item => item.Line)
.OrderBy(item => item.Column);
}
A Few Examples: A Tricky Detail
• The analyzer can recognize bug patterns your team don’t even know
of.
static class Profiler
{
[ThreadStatic]
private static Stopwatch timer = new Stopwatch();
....
Mono
V3089 Initializer of a field marked by [ThreadStatic] attribute will be called once on the first
accessing thread. The field will have default value on different threads. System.Data.Linq-
net_4_x Profiler.cs 16
More examples towards the end
The Biggest Mistake Made When Using Static
Analyzers
• One-time checks have little effect
• Think of it by analogy with compiler warnings
• Everything really bad has been already fixed using other means;
you have only minor defects and heisenbugs left
False Positives
• These are an unavoidable evil, but static analyzers provide various
means to tackle them
• Means of dealing with false positives in PVS-Studio
• selective warning suppression
• selective exclusion of folders/files from analysis
• selective disabling of diagnostics
• suppression markup base, which is the most important
feature – more on this in the next slides
PVS-Studio. The Idea Behind the Suppression
Markup Base
• Allows you to start using the analyzer immediately on newly written
or modified code
• Old bugs are unlikely to be critical, so you could get back to them
later when you have time for that
Getting Started with the Suppression Base
1. Check the project
2. Mark all the warnings produced by the analyzer as irrelevant
3. Submit the file with the base to the version control system
4. PROFIT
A Bit More About PVS-Studio
• You can set PVS-Studio to launch on the server
• And use the BlameNotifier utility to send emails to those developers
who submitted faulty code
Why So Much Talk About Regular Use?
• Here’s a comment by a PVS-Studio user: "A User's Experience of
Working with the Analyzer" - https://www.viva64.com/en/b/0221/
The conclusion is: the bug we had wasted about 50 hours to track was
detected at once with the first run of the analyzer and fixed in less
than an hour!
Alexander Lotokhov
SonarQube: Data Visualization
• Open-source platform for continuous inspection of code quality
• Comes with a number of analyzers, including Sonar C#
• Nice visualization
SonarQube: Nice Visualization
SonarQube: Integration with Third-Party
Analyzers. What For?
• The strong point of Sonar C# is measuring the code quality (detection
of "code smells")
• The weak point of Sonar C# is that it offers too few diagnostics to
detect bugs leading to incorrect program operation
SonarQube: Integration with Third-Party
Analyzers
• A way out: integration with other analyzers
• Such as PVS-Studio
• PVS-Studio is especially good at detecting real bugs and typos
• 137 diagnostics to detect bugs in C# code
Example: Analysis of PascalABC.NET using SonarQube plugins: SonarC#
and PVS-Studio - https://www.viva64.com/en/b/0492/
SonarQube + PVS-Studio
The Second Biggest Mistake
• Myth: static analyzers are tools for beginner programmers!
• Myth: we are pros and we never mistype!
• We all make mistakes. What’s more, we are prone to making mistakes
in certain situations.
• Here’s an article by Andrey Karpov to illustrate this:
The Evil within the Comparison Functions
No Aliens to Blame
IronPython and IronRuby
public static int Compare(SourceLocation left,
SourceLocation right) {
if (left < right) return -1;
if (right > left) return 1;
return 0;
}
PVS-Studio warning (C#): V3021 There are two 'if' statements with identical conditional
expressions. The first 'if' statement contains method return. This means that the second 'if'
statement is senseless. SourceLocation.cs 156
The Evil Within the Comparison Functions
SharpDevelop
public int Compare(SharpTreeNode x, SharpTreeNode y)
{
....
if (typeNameComparison == 0) {
if (x.Text.ToString().Length < y.Text.ToString().Length)
return -1;
if (x.Text.ToString().Length < y.Text.ToString().Length)
return 1;
PVS-Studio warning: V3021 There are two 'if' statements with identical conditional
expressions. The first 'if' statement contains method return. This means that the second 'if'
statement is senseless NamespaceTreeNode.cs 87
The Evil Within the Comparison Functions
public int Compare(GlyphRun a, GlyphRun b)
{
....
if (aPoint.Y > bPoint.Y)
{
return -1;
}
else if (aPoint.Y > bPoint.Y)
{
result = 1;
}
else if (aPoint.X < bPoint.X)
....
WPF samples by Microsoft
PVS-Studio warning: V3003 The use of 'if (A)
{...} else if (A) {...}' pattern was detected.
There is a probability of logical error presence.
Check lines: 418, 422. txtserializerwriter.cs
418
The Evil Within the Comparison Functions
• Link to the article:
https://www.viva64.com/en/b/0509/
Conclusions:
• Static analysis is a means to find a portion of bugs right away before
they get expensive
• Static analysis must be used on a regular basis
• You can start using it right away, putting the old bugs aside to deal
with them later
• C#-programmers may want to check out SonarQube (Sonar С#) and
PVS-Studio
Useful Links
• List of tools for static code analysis
https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis
• PVS-Studio
https://www.viva64.com/en/pvs-studio/
• SonaqQube
https://www.sonarqube.org/
Q&A
www.viva64.com
support@viva64.com
More Examples if There’s Time Left
Umbraco
protected virtual void OnBeforeNodeRender(ref XmlTree sender,
ref XmlTreeNode node,
EventArgs e)
{
if (node != null && node != null)
{
if (BeforeNodeRender != null)
BeforeNodeRender(ref sender, ref node, e);
}
}
PVS-Studio: V3001 There are identical sub-expressions 'node != null' to the left and to the
right of the '&&' operator.
More Examples if There’s Time Left
CodeContracts
if (mTypeConstraint == TypeConstraint.CLASS)
{
oh.Output("class", false); comma = true;
}
else if (mTypeConstraint == TypeConstraint.STRUCT)
.....
else if (mTypeConstraint == TypeConstraint.CLASS)
{
oh.Output(mClassConstraint, false); comma = true;
}
PVS-Studio: V3003 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a
probability of logical error presence.
More Examples if There’s Time Left
CodeContracts
for (int i = 0; i < data.Length; i++)
{
if (data[i] != null)
{
for (int j = 0; j < lastElement[i]; i++)
{
str.AppendFormat("({0},{1})",
data[i][j].Index, data[i][j].Value);
}
}
}
PVS-Studio: V3014 It is likely that a wrong variable is being incremented inside the 'for'
operator. Consider reviewing 'i'.
More Examples if There’s Time Left
Orleans
public static string SanitizeTableProperty(string key)
{
key.Replace('/', '_'); // Forward slash
key.Replace('', '_'); // Backslash
key.Replace('#', '_'); // Pound sign
key.Replace('?', '_'); // Question mark
....
return key;
}
PVS-Studio: V3010 The return value of function 'Replace' is required to be utilized.
More Examples if There’s Time Left
SharpDevelop
public WhitespaceNode(string whiteSpaceText,
TextLocation startLocation)
{
this.WhiteSpaceText = WhiteSpaceText;
this.startLocation = startLocation;
}
PVS-Studio: V3005 The 'this.WhiteSpaceText' variable is assigned to itself.
www.viva64.com40
More Examples if There’s Time Left
SharpDevelop
ContentPropertyNode clickedNode =
clickedButton.DataContext as ContentPropertyNode;
clickedNode = clickedButton.DataContext as ContentPropertyNode;
if (clickedNode == null)
Redundant code.
PVS-Studio: V3008 The 'clickedNode' variable is assigned values twice successively.
Perhaps this is a mistake.
More Examples if There’s Time Left
SharpDevelop
public override string ToString()
{
return
String.Format("[Line {0}:{1,2}-{3,4}:{5}]",
File, Row, Column, EndRow, EndColumn, Offset);
}
PVS-Studio: V3025 Incorrect format. A different number of actual arguments is expected
while calling 'Format' function. Expected: 4. Present: 6.
More Examples if There’s Time Left
GitExtensions
if (string.IsNullOrEmpty(translationCategory.Name))
new InvalidOperationException(
"Cannot add translationCategory without name");
PVS-Studio: V3006 The object was created but it is not being used. The 'throw' keyword
could be missing: throw new InvalidOperationException(FOO).
throw
More Examples if There’s Time Left
Orleans
if (numRemoved > 0)
if (logger.IsVerbose) logger.Verbose(....);
else
if (logger.IsVerbose2) logger.Verbose2(....);
PVS-Studio: V3033 It is possible that this 'else' branch must apply to the previous 'if'
statement. Interner.cs 274
MSBuild (ResolveSDKReference_Tests.cs)
installedSDK.SetMetadata("SDKName", "GoodTestSDK, Version=2.0");
t.InstalledSDKs = new ITaskItem[] { installedSDK };
t.TargetedSDKConfiguration = "Debug";
t.TargetedSDKConfiguration = "x86";
t.BuildEngine = engine;
PVS-Studio: V3008 The 't.TargetedSDKConfiguration' variable is assigned values twice
successively. Perhaps this is a mistake.
t.TargetedSDKArchitecture
• A nice example of how static analysis complements unit testing
More Examples if There’s Time Left
More Examples if There’s Time Left
CruiseControl.NET
public void ModificationsAreComparedByModifiedDatetime()
{
Modification alpha = new Modification();
alpha.ModifiedTime = new DateTime(1975, 3, 3);
Modification beta = new Modification();
alpha.ModifiedTime = new DateTime(1961, 3, 3);
....
}
PVS-Studio: V3008 The 'alpha.ModifiedTime' variable is assigned values twice
successively. Perhaps this is a mistake.
Xamarin.Forms (C#)
internal bool IsDefault
{
get { return Left == 0 && Top == 0 &&
Right == 0 && Left == 0; }
}
V3001 There are identical sub-expressions 'Left == 0' to the left and to the right of the '&&'
operator. Thickness.cs 29
More Examples if There’s Time Left
Space Engineers (C#)
void DeserializeV0(XmlReader reader)
{
....
if (property.Name == "Rotation" ||
property.Name == "AxisScale" ||
property.Name == "AxisScale")
continue;
....
}
More Examples if There’s Time Left
V3001 There are identical sub-expressions 'property.Name == "AxisScale"' to the left and to
the right of the '||' operator. Sandbox.Graphics MyParticleEmitter.cs 352
A lot more examples:
https://www.viva64.com/en/examples/
The End

More Related Content

What's hot

SophiaConf 2018 - P. Urso (Activeeon)
SophiaConf 2018 - P. Urso (Activeeon)SophiaConf 2018 - P. Urso (Activeeon)
SophiaConf 2018 - P. Urso (Activeeon)TelecomValley
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioPVS-Studio
 
Agile analysis development
Agile analysis developmentAgile analysis development
Agile analysis developmentsetitesuk
 
150412 38 beamer methods of binary analysis
150412 38 beamer methods of  binary analysis150412 38 beamer methods of  binary analysis
150412 38 beamer methods of binary analysisRaghu Palakodety
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShareyayao
 
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016jtmelton
 
Checking PVS-Studio with Clang
Checking PVS-Studio with ClangChecking PVS-Studio with Clang
Checking PVS-Studio with ClangAndrey Karpov
 
AppSensor CodeMash 2017
AppSensor CodeMash 2017AppSensor CodeMash 2017
AppSensor CodeMash 2017jtmelton
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveAlvaro Videla
 
PVS-Studio Has Finally Got to Boost
PVS-Studio Has Finally Got to BoostPVS-Studio Has Finally Got to Boost
PVS-Studio Has Finally Got to BoostAndrey Karpov
 
How penetration testing techniques can help you improve your qa skills
How penetration testing techniques can help you improve your qa skillsHow penetration testing techniques can help you improve your qa skills
How penetration testing techniques can help you improve your qa skillsMarian Marinov
 
National software testing conference 2016 fergal hynes
National software testing conference 2016 fergal hynesNational software testing conference 2016 fergal hynes
National software testing conference 2016 fergal hynesFergal Hynes
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroPaul Boos
 

What's hot (20)

SophiaConf 2018 - P. Urso (Activeeon)
SophiaConf 2018 - P. Urso (Activeeon)SophiaConf 2018 - P. Urso (Activeeon)
SophiaConf 2018 - P. Urso (Activeeon)
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-Studio
 
Agile analysis development
Agile analysis developmentAgile analysis development
Agile analysis development
 
150412 38 beamer methods of binary analysis
150412 38 beamer methods of  binary analysis150412 38 beamer methods of  binary analysis
150412 38 beamer methods of binary analysis
 
Tdd - introduction
Tdd - introductionTdd - introduction
Tdd - introduction
 
Parasoft fda software compliance part2
Parasoft fda software compliance   part2Parasoft fda software compliance   part2
Parasoft fda software compliance part2
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare
 
PHP - Introduction to PHP Bugs - Debugging
PHP -  Introduction to  PHP Bugs - DebuggingPHP -  Introduction to  PHP Bugs - Debugging
PHP - Introduction to PHP Bugs - Debugging
 
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Checking PVS-Studio with Clang
Checking PVS-Studio with ClangChecking PVS-Studio with Clang
Checking PVS-Studio with Clang
 
AppSensor CodeMash 2017
AppSensor CodeMash 2017AppSensor CodeMash 2017
AppSensor CodeMash 2017
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = Love
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
PVS-Studio Has Finally Got to Boost
PVS-Studio Has Finally Got to BoostPVS-Studio Has Finally Got to Boost
PVS-Studio Has Finally Got to Boost
 
How penetration testing techniques can help you improve your qa skills
How penetration testing techniques can help you improve your qa skillsHow penetration testing techniques can help you improve your qa skills
How penetration testing techniques can help you improve your qa skills
 
National software testing conference 2016 fergal hynes
National software testing conference 2016 fergal hynesNational software testing conference 2016 fergal hynes
National software testing conference 2016 fergal hynes
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
Integration testing
Integration testingIntegration testing
Integration testing
 

Similar to Static Code Analysis: Keeping the Cost of Bug Fixing Down

All about PVS-Studio
All about PVS-StudioAll about PVS-Studio
All about PVS-StudioPVS-Studio
 
Topic production code
Topic production codeTopic production code
Topic production codeKavi Kumar
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS DebuggingRami Sayar
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingFITC
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
How PVS-Studio does the bug search: methods and technologies
How PVS-Studio does the bug search: methods and technologiesHow PVS-Studio does the bug search: methods and technologies
How PVS-Studio does the bug search: methods and technologiesPVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codeAndrey Karpov
 
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...Lucas Sacramento
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxShivashankarHR1
 
Next Generation Architecture Showcase July 2019
Next Generation Architecture Showcase July 2019Next Generation Architecture Showcase July 2019
Next Generation Architecture Showcase July 2019Alan Pearson Mathews
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4Andrey Karpov
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using JenkinsRogue Wave Software
 
How to Test PowerShell Code Using Pester
How to Test PowerShell Code Using PesterHow to Test PowerShell Code Using Pester
How to Test PowerShell Code Using PesterChris Wahl
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio
 
Three Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersThree Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersAndrey Karpov
 
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...Andrey Karpov
 
App Assessments Reloaded
App Assessments ReloadedApp Assessments Reloaded
App Assessments ReloadedErnest Mueller
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with PythonAbhay Bhargav
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Dinis Cruz
 
Static Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to IntegrationStatic Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to IntegrationAndrey Karpov
 

Similar to Static Code Analysis: Keeping the Cost of Bug Fixing Down (20)

All about PVS-Studio
All about PVS-StudioAll about PVS-Studio
All about PVS-Studio
 
Topic production code
Topic production codeTopic production code
Topic production code
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
How PVS-Studio does the bug search: methods and technologies
How PVS-Studio does the bug search: methods and technologiesHow PVS-Studio does the bug search: methods and technologies
How PVS-Studio does the bug search: methods and technologies
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...
CarTrawler's Feature Team Architecture and Development Process Showcase by Lu...
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptx
 
Next Generation Architecture Showcase July 2019
Next Generation Architecture Showcase July 2019Next Generation Architecture Showcase July 2019
Next Generation Architecture Showcase July 2019
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using Jenkins
 
How to Test PowerShell Code Using Pester
How to Test PowerShell Code Using PesterHow to Test PowerShell Code Using Pester
How to Test PowerShell Code Using Pester
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
Three Interviews About Static Code Analyzers
Three Interviews About Static Code AnalyzersThree Interviews About Static Code Analyzers
Three Interviews About Static Code Analyzers
 
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...
PVS-Studio and CppCat: An Interview with Andrey Karpov, the Project CTO and D...
 
App Assessments Reloaded
App Assessments ReloadedApp Assessments Reloaded
App Assessments Reloaded
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Python
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
 
Static Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to IntegrationStatic Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to Integration
 

More from Andrey Karpov

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программистаAndrey Karpov
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developerAndrey Karpov
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Andrey Karpov
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesAndrey Karpov
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewAndrey Karpov
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокAndrey Karpov
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Andrey Karpov
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesAndrey Karpov
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?Andrey Karpov
 
Typical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaTypical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaAndrey Karpov
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)Andrey Karpov
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Andrey Karpov
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareAndrey Karpov
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineAndrey Karpov
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsAndrey Karpov
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++Andrey Karpov
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youAndrey Karpov
 

More from Andrey Karpov (20)

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developer
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature Overview
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибок
 
PVS-Studio в 2021
PVS-Studio в 2021PVS-Studio в 2021
PVS-Studio в 2021
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' Mistakes
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?
 
Typical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaTypical errors in code on the example of C++, C#, and Java
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)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal Engine
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for you
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 

Recently uploaded (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

Static Code Analysis: Keeping the Cost of Bug Fixing Down

  • 1. PVS-Studio Team www.viva64.com Static Code Analysis: Keeping the Cost of Bug Fixing Down
  • 2. Bugs Have Always Been and Will Always Be There • No use preaching "careful coding" • Bugs have always been and will always be there • Everybody knows bugs should be fixed • People forget that bugs should be fixed at the lowest cost possible in terms of time and money!
  • 3. Too Many Heroes Are a Bad Sign • You may enjoy telling people how your team spent a week heroically hunting for a bug • But the fact that your team has to perform such feats does it no credit This city code needs a hero!
  • 4.
  • 5.
  • 6. The Sooner You Fix, the Better • Depending on the bug pattern, fixing at the coding stage is 10–100 times cheaper than after the release • Various techniques are available: • code review • unit testing (or TDD) • testing a new feature by its author • dynamic code analysis (a variation of testing) • static analysis, which will be discussed further
  • 7. What Code Review Is • Code is examined by several programmers • Ideally, they shouldn’t be using a computer • They give their comments and advice on what to fix and improve
  • 8. Pros of Code Review by Humans • You can find complex bugs • You can find high-level defects (such as slow algorithms)
  • 9. Cons of Code Review by Humans • There could be bugs none of the reviewers is aware of • It’s expensive • Humans get tired fast
  • 10. Static Analysis as a Compromise • Pros of analyzers: • they check the entire code • they don’t get tired • they can recognize tricky bug patterns • Cons: • they are just programs, not an AI • They are definitely useful thanks to immediate detection of bugs • Analogy: the spell check in Microsoft Word.
  • 11. Static Analysis Tools • We’ll take PVS-Studio as an example • But there are many other tools to fit any taste: • FxCop • Klocwork • Parasoft • SonarQube • Veracode • More: https://en.Wikipedia.org/wiki/List_of_tools_for_static_code_analysis
  • 12. A Few Examples: A Typo static bool AreEqual (VisualStyleElement value1, VisualStyleElement value2) { return value1.ClassName == value1.ClassName && value1.Part == value2.Part && value1.State == value2.State; } PVS-Studio: V3001 There are identical sub-expressions 'value1.ClassName' to the left and to the right of the '==' operator. ThemeVisualStyles.cs 2141 Mono
  • 13. A Few Examples: Coding in a Hurry void IBackgroundTask.Sweep() { .... // Don't flood the database with progress updates; // Limit it to every 5 seconds. if ((_clock.UtcNow - lastUpdateUtc).Seconds >= 5) { .... PVS-Studio: V3118 Seconds component of TimeSpan is used, which does not represent full time interval. Possibly 'TotalSeconds' value was intended instead. AssetUploader.cs 182 Orchard CMS should be TotalSeconds
  • 14. A Few Examples: Sorting PVS-Studio: V3078 Original sorting order will be lost after repetitive call to 'OrderBy' method. Use 'ThenBy' method to preserve the original sorting. CodeCoverageMethodElement.cs 124 SharpDevelop void Init() { .... this.SequencePoints.OrderBy(item => item.Line) .OrderBy(item => item.Column); }
  • 15. A Few Examples: A Tricky Detail • The analyzer can recognize bug patterns your team don’t even know of. static class Profiler { [ThreadStatic] private static Stopwatch timer = new Stopwatch(); .... Mono V3089 Initializer of a field marked by [ThreadStatic] attribute will be called once on the first accessing thread. The field will have default value on different threads. System.Data.Linq- net_4_x Profiler.cs 16
  • 17. The Biggest Mistake Made When Using Static Analyzers • One-time checks have little effect • Think of it by analogy with compiler warnings • Everything really bad has been already fixed using other means; you have only minor defects and heisenbugs left
  • 18. False Positives • These are an unavoidable evil, but static analyzers provide various means to tackle them • Means of dealing with false positives in PVS-Studio • selective warning suppression • selective exclusion of folders/files from analysis • selective disabling of diagnostics • suppression markup base, which is the most important feature – more on this in the next slides
  • 19. PVS-Studio. The Idea Behind the Suppression Markup Base • Allows you to start using the analyzer immediately on newly written or modified code • Old bugs are unlikely to be critical, so you could get back to them later when you have time for that
  • 20. Getting Started with the Suppression Base 1. Check the project 2. Mark all the warnings produced by the analyzer as irrelevant 3. Submit the file with the base to the version control system 4. PROFIT
  • 21. A Bit More About PVS-Studio • You can set PVS-Studio to launch on the server • And use the BlameNotifier utility to send emails to those developers who submitted faulty code
  • 22. Why So Much Talk About Regular Use? • Here’s a comment by a PVS-Studio user: "A User's Experience of Working with the Analyzer" - https://www.viva64.com/en/b/0221/ The conclusion is: the bug we had wasted about 50 hours to track was detected at once with the first run of the analyzer and fixed in less than an hour! Alexander Lotokhov
  • 23. SonarQube: Data Visualization • Open-source platform for continuous inspection of code quality • Comes with a number of analyzers, including Sonar C# • Nice visualization
  • 25. SonarQube: Integration with Third-Party Analyzers. What For? • The strong point of Sonar C# is measuring the code quality (detection of "code smells") • The weak point of Sonar C# is that it offers too few diagnostics to detect bugs leading to incorrect program operation
  • 26. SonarQube: Integration with Third-Party Analyzers • A way out: integration with other analyzers • Such as PVS-Studio • PVS-Studio is especially good at detecting real bugs and typos • 137 diagnostics to detect bugs in C# code Example: Analysis of PascalABC.NET using SonarQube plugins: SonarC# and PVS-Studio - https://www.viva64.com/en/b/0492/
  • 28. The Second Biggest Mistake • Myth: static analyzers are tools for beginner programmers! • Myth: we are pros and we never mistype! • We all make mistakes. What’s more, we are prone to making mistakes in certain situations. • Here’s an article by Andrey Karpov to illustrate this: The Evil within the Comparison Functions
  • 29. No Aliens to Blame IronPython and IronRuby public static int Compare(SourceLocation left, SourceLocation right) { if (left < right) return -1; if (right > left) return 1; return 0; } PVS-Studio warning (C#): V3021 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless. SourceLocation.cs 156
  • 30. The Evil Within the Comparison Functions SharpDevelop public int Compare(SharpTreeNode x, SharpTreeNode y) { .... if (typeNameComparison == 0) { if (x.Text.ToString().Length < y.Text.ToString().Length) return -1; if (x.Text.ToString().Length < y.Text.ToString().Length) return 1; PVS-Studio warning: V3021 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless NamespaceTreeNode.cs 87
  • 31. The Evil Within the Comparison Functions public int Compare(GlyphRun a, GlyphRun b) { .... if (aPoint.Y > bPoint.Y) { return -1; } else if (aPoint.Y > bPoint.Y) { result = 1; } else if (aPoint.X < bPoint.X) .... WPF samples by Microsoft PVS-Studio warning: V3003 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 418, 422. txtserializerwriter.cs 418
  • 32. The Evil Within the Comparison Functions • Link to the article: https://www.viva64.com/en/b/0509/
  • 33. Conclusions: • Static analysis is a means to find a portion of bugs right away before they get expensive • Static analysis must be used on a regular basis • You can start using it right away, putting the old bugs aside to deal with them later • C#-programmers may want to check out SonarQube (Sonar С#) and PVS-Studio
  • 34. Useful Links • List of tools for static code analysis https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis • PVS-Studio https://www.viva64.com/en/pvs-studio/ • SonaqQube https://www.sonarqube.org/
  • 36. More Examples if There’s Time Left Umbraco protected virtual void OnBeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e) { if (node != null && node != null) { if (BeforeNodeRender != null) BeforeNodeRender(ref sender, ref node, e); } } PVS-Studio: V3001 There are identical sub-expressions 'node != null' to the left and to the right of the '&&' operator.
  • 37. More Examples if There’s Time Left CodeContracts if (mTypeConstraint == TypeConstraint.CLASS) { oh.Output("class", false); comma = true; } else if (mTypeConstraint == TypeConstraint.STRUCT) ..... else if (mTypeConstraint == TypeConstraint.CLASS) { oh.Output(mClassConstraint, false); comma = true; } PVS-Studio: V3003 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence.
  • 38. More Examples if There’s Time Left CodeContracts for (int i = 0; i < data.Length; i++) { if (data[i] != null) { for (int j = 0; j < lastElement[i]; i++) { str.AppendFormat("({0},{1})", data[i][j].Index, data[i][j].Value); } } } PVS-Studio: V3014 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'.
  • 39. More Examples if There’s Time Left Orleans public static string SanitizeTableProperty(string key) { key.Replace('/', '_'); // Forward slash key.Replace('', '_'); // Backslash key.Replace('#', '_'); // Pound sign key.Replace('?', '_'); // Question mark .... return key; } PVS-Studio: V3010 The return value of function 'Replace' is required to be utilized.
  • 40. More Examples if There’s Time Left SharpDevelop public WhitespaceNode(string whiteSpaceText, TextLocation startLocation) { this.WhiteSpaceText = WhiteSpaceText; this.startLocation = startLocation; } PVS-Studio: V3005 The 'this.WhiteSpaceText' variable is assigned to itself. www.viva64.com40
  • 41. More Examples if There’s Time Left SharpDevelop ContentPropertyNode clickedNode = clickedButton.DataContext as ContentPropertyNode; clickedNode = clickedButton.DataContext as ContentPropertyNode; if (clickedNode == null) Redundant code. PVS-Studio: V3008 The 'clickedNode' variable is assigned values twice successively. Perhaps this is a mistake.
  • 42. More Examples if There’s Time Left SharpDevelop public override string ToString() { return String.Format("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset); } PVS-Studio: V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 4. Present: 6.
  • 43. More Examples if There’s Time Left GitExtensions if (string.IsNullOrEmpty(translationCategory.Name)) new InvalidOperationException( "Cannot add translationCategory without name"); PVS-Studio: V3006 The object was created but it is not being used. The 'throw' keyword could be missing: throw new InvalidOperationException(FOO). throw
  • 44. More Examples if There’s Time Left Orleans if (numRemoved > 0) if (logger.IsVerbose) logger.Verbose(....); else if (logger.IsVerbose2) logger.Verbose2(....); PVS-Studio: V3033 It is possible that this 'else' branch must apply to the previous 'if' statement. Interner.cs 274
  • 45. MSBuild (ResolveSDKReference_Tests.cs) installedSDK.SetMetadata("SDKName", "GoodTestSDK, Version=2.0"); t.InstalledSDKs = new ITaskItem[] { installedSDK }; t.TargetedSDKConfiguration = "Debug"; t.TargetedSDKConfiguration = "x86"; t.BuildEngine = engine; PVS-Studio: V3008 The 't.TargetedSDKConfiguration' variable is assigned values twice successively. Perhaps this is a mistake. t.TargetedSDKArchitecture • A nice example of how static analysis complements unit testing More Examples if There’s Time Left
  • 46. More Examples if There’s Time Left CruiseControl.NET public void ModificationsAreComparedByModifiedDatetime() { Modification alpha = new Modification(); alpha.ModifiedTime = new DateTime(1975, 3, 3); Modification beta = new Modification(); alpha.ModifiedTime = new DateTime(1961, 3, 3); .... } PVS-Studio: V3008 The 'alpha.ModifiedTime' variable is assigned values twice successively. Perhaps this is a mistake.
  • 47. Xamarin.Forms (C#) internal bool IsDefault { get { return Left == 0 && Top == 0 && Right == 0 && Left == 0; } } V3001 There are identical sub-expressions 'Left == 0' to the left and to the right of the '&&' operator. Thickness.cs 29 More Examples if There’s Time Left
  • 48. Space Engineers (C#) void DeserializeV0(XmlReader reader) { .... if (property.Name == "Rotation" || property.Name == "AxisScale" || property.Name == "AxisScale") continue; .... } More Examples if There’s Time Left V3001 There are identical sub-expressions 'property.Name == "AxisScale"' to the left and to the right of the '||' operator. Sandbox.Graphics MyParticleEmitter.cs 352
  • 49. A lot more examples: https://www.viva64.com/en/examples/