Mais conteúdo relacionado Semelhante a Static Code Analysis (20) Mais de Annyce Davis (17) Static Code Analysis6. 1 / 7 - 10
@brwngrldev
13. apply plugin: ‘checkstyle’
task checkstyle(type: Checkstyle) {
description 'Checks if the code passes quality standards'
group 'verification'
configFile file(‘checkstyle.xml')
…
}
14. <module name=“MethodLength">
<property name="max" value=“60"/>
</module>
<module name=“LineLength">
<property name="max" value=“120"/>
</module>
<module name=“CyclomaticComplexity">
<property name="max" value=“8"/>
</module>
…
playerControlConfig.setShowClosedCaptionsButton(a.getBo
17. public void overlyComplexMethod(Video video) {
if (video != null && video.getStreamUrl() != null) {
switch (video.getCategory()) {
case "CAT1" :
playVideo(video);
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.largeImage.png");
}
updateMetadata(video);
break;
case "CAT2" :
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.smallImage.png");
19. public void overlyComplexMethod(Video video) {
if (video != null && video.getStreamUrl() != null) {
updateVideoBasedOnCategory(video);
}
}
private void updateVideoBasedOnCategory(Video video) {
switch (video.getCategory()) {
case "CAT1" :
playVideo(video);
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.largeImage.png");
}
updateMetadata(video);
break;
7
24. apply plugin: ‘findbugs’
task findbugs(type: FindBugs) {
description 'Run findbugs'
group 'verification'
effort 'max'
excludeFilter file('findbugs-exclude.xml')
…
}
33. apply plugin: ‘pmd’
task pmd(type: Pmd) {
description 'Run pmd'
group 'verification'
ruleSetFiles = files("./qa-checks/pmd-ruleset.xml")
…
}
51. Resources
• Clean Code - http://amzn.to/1DJybxH
• Effective Java - http://amzn.to/1Ku8Xel
• Google Code Style - http://goo.gl/8Pf6J3
• QA Checks - http://git.io/vCMwc
• Conquering Cyclomatic Complexity - http://goo.gl/lRoPXN
• Using Android Lint - http://goo.gl/Zl2BPx
• Static Code Analysis Tools - https://goo.gl/0Hczxn
@brwngrldev
52. Photo Credits
• Slide 7 - https://www.flickr.com/photos/orinrobertjohn/13068719
• Slide 20 - https://www.flickr.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-fan-
faust-328420/
@brwngrldev