Ill be learning
something new
on my deathbed.
@brwngrldev
+AnnyceDavis
What is it?
Checking your program for errors
without executing it
@brwngrldev
Testing
@brwngrldev
1 / 7 - 10
@brwngrldev
1 / 10
1000
@brwngrldev
The tools
Checkstyle
@brwngrldev
FindBugs
PMD
Lint
Checkstyle
Lint
FindBugs
PMD
@brwngrldev
Checkstyle
a development tool to help
programmers write Java code that
adheres to a coding standard.
Modules
Source
Files
Design
Checkstyle Tool
config.xml
Formatting
Code Complexity
congFile le(checkstyle.xml')
<module name=MethodLength">
<property name="max" value=60"/>
</module>
playerControlCong.setShowClosedCaptionsButton(a.getBo
<module name=LineLength">
<property name="max" value=120"/>
</module>
<module name=CyclomaticComplexity">
<property name="max" value=8"/>
</module>
<module name=CyclomaticComplexity">
<property name="max" value=8"/>
</module>
Example
switch (video.getCategory()) {
case "CAT1" :
playVideo(video);
updateMetaDataAndUrl(video, "http://www.largeImage.png");
break;
@brwngrldev
Review
Code
Complexity
Refactor
Gradually
Formatting
Checkstyle
@brwngrldev
FindBugs
But this
inspect Java bytecode
for occurrences of bug
patterns
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Bug pattern="HE_EQUALS_NO_HASHCODE"/>
</Match>
</FindBugsFilter>
Example
gradle findbugs
Review
Not
Always
Right
Use
the
Filters
Bug Patterns
FindBugs
@brwngrldev
PMD
nds common programming aws like
unused variables, empty catch blocks
<ruleset>
<rule ref="rulesets/java/braces.xml" />
<rule ref="rulesets/java/strings.xml" />
<rule ref="rulesets/java/basic.xml" />
</ruleset>
Braces Ruleset
Example
gradle pmd
Fix it
Review
Wasteful
Usage
Duplicate
Code
Possible Bugs
PMD
@brwngrldev
Ewww!!!
Lint
checks for structural code problems that
could aect the quality and performance of
your application.
cpplint
Lintian
PyLint
PC-Lint
Android Lint Splint JSLint
Example
Android Lint
<lint>
<issue id="IconColors" severity="ignore" />
<issue id="UnusedResources">
<ignore path="**/cong.xml" />
</issue>
</lint>
Continous Integration
Review
Exclude
Checks
Continuous
Integration
Structural Issues
Lint
@brwngrldev
Summary
Checkstyle
FindBugs
PMD
Lint
@brwngrldev
Resources
@brwngrldev
Photo Credits
Slide 7 - https://www.ickr.com/photos/orinrobertjohn/13068719
Slide 20 - https://www.ickr.com/photos/oakleyoriginals/2750185692
Slide 41 - https://commons.wikimedia.org/wiki/File:Navel_lint_ball.jpg
Slide 50 - https://pixabay.com/en/thumb-success-successful-fanfaust-328420/
@brwngrldev
Thanks!
@brwngrldev
+AnnyceDavis
www.adavis.info