SlideShare a Scribd company logo
Code Quality
Assurance with PMD
(ongoing cleanups)
Herold Business Data
2004 to 2006


   Peter Kofler, ‘Code Cop’
       @codecopkofler
     www.code-cop.org
 Copyright Peter Kofler, licensed under CC-BY.
PETER KOFLER, CODE-COP.ORG                  FANATIC ABOUT CODE QUALITY




                             Peter Kofler
  • Ph.D. in Applied Math

  • Professional Software
    Developer

  • Developer at Herold Business Data

  • “fanatic about code quality”
Agenda
PETER KOFLER, CODE-COP.ORG   FANATIC ABOUT CODE QUALITY




        Status Daily Build
        Static Code Analysis
        Rule Categorisation
        Rules to fix/obey ;-)
PETER KOFLER, CODE-COP.ORG                 FANATIC ABOUT CODE QUALITY




                             Daily Build
  • Since three months
  • Trunk is compiling (at least more often)
        – missing files 
        – shared subproject complexity 
  • Build history
  • JavaDoc
  • XML validation
PETER KOFLER, CODE-COP.ORG                  FANATIC ABOUT CODE QUALITY




                             Next Steps

  • Static code analysis
        – check the source

  • JUnit integration
        – of few existing tests

  • Initialise application
        – integration tests (that would be cool)
Static Analysis
PETER KOFLER, CODE-COP.ORG             FANATIC ABOUT CODE QUALITY




          PMD Static Code Analyser
  • http://pmd.sourceforge.net/
  • Scans Java source
  • JavaCC-generated parser
        – Abstract Syntax Tree (AST)
  • Traverses AST
  • Reports violations
PETER KOFLER, CODE-COP.ORG                    FANATIC ABOUT CODE QUALITY




                             Eclipse Plugin
  • Install pmd-eclipse2-site-2.0RC3.zip
  • Patch plugin with current PMD:
        – extract pmd.jar from pmd-bin-1.5.zip
        – rename to pmd-1.3.jar and replace in
          pluginsnet.sourceforge.pmd.core_1.3.2lib
  • Customise rules:
        – delete all and import PMD20040427.xml
Rule
Categorisation
PETER KOFLER, CODE-COP.ORG             FANATIC ABOUT CODE QUALITY




                             “Error”

  • Really serious errors
        – e.g. bad practice
        – or correctness bugs

  • Currently (only ;-) 125
       in whole code base
PETER KOFLER, CODE-COP.ORG               FANATIC ABOUT CODE QUALITY




                             “Warning”
  • Other errors




  • Currently 4023
PETER KOFLER, CODE-COP.ORG            FANATIC ABOUT CODE QUALITY




                    “Info” (Information)
  • Minor errors
        – e.g. performance problems



  • Currently 4091
PETER KOFLER, CODE-COP.ORG              FANATIC ABOUT CODE QUALITY




                             “Format”
  • Formatting Problems
        – e.g. code style violations



  • Currently 6834
Fix It!
PETER KOFLER, CODE-COP.ORG                   FANATIC ABOUT CODE QUALITY




                             “Fix” Process
  • Activate not (yet) triggered rules
        – make sure there are no new violations
  • Fix few “bad guys” first
  • Activate their rules
  • Choose next error from list, repeat
  • In the end only low priority bugs left
PETER KOFLER, CODE-COP.ORG           FANATIC ABOUT CODE QUALITY




                   Not Triggered Errors
  •    BadComparison if (y == Double.NaN)
  •    EmptyFinalizer
  •    FinalizeOnlyCallsSuperFinalize
  •    FinalizeOverloaded
  •    ShortMethodName (<= 3)
  •    SuspiciousHashcodeMethodName
       public int hashcode() // <-> hashCode
PETER KOFLER, CODE-COP.ORG           FANATIC ABOUT CODE QUALITY



  • EmptyWhileStmt
    while (a == b) {
       // maybe here was some code before
    }
  • NonStaticInitializer
    // public void doSomething()
    {
       // this block gets run before any
       // call to any constructor
       System.out.println("construct myself");
    }
PETER KOFLER, CODE-COP.ORG          FANATIC ABOUT CODE QUALITY



             MethodWithSameName
               AsEnclosingClass

  public class MyClass
  {
    // bad because it is a method
    public void MyClass() { }
    // OK because it is a constructor
    public MyClass() { }
  }
PETER KOFLER, CODE-COP.ORG                  FANATIC ABOUT CODE QUALITY



  • JumbledIncrementer
    for (int i = 0; i < 10; i++) {
      for (int k = 0; k < 20; i++) {
        System.out.println("Hello");
      }
    }
  • NonCaseLabelInSwitchStatement
       switch (a) {
         case 1 : // do something
                  break;
         mylabel : // legal but confusing
                  break;
       }
PETER KOFLER, CODE-COP.ORG     FANATIC ABOUT CODE QUALITY




             Not Triggered Warnings
  • DefaultLabelNotLastInSwitchStmt
  • DontImportJavaLang
  • EmptyStaticInitializer
  • EmptySwitchStatements
  • EmptySynchronizedBlock
  • EmptyTryBlock &
    EmptyFinallyBlock
  • ImportFromSamePackage
PETER KOFLER, CODE-COP.ORG          FANATIC ABOUT CODE QUALITY



  • ForLoopShouldBeWhileLoop
    for (; true;) {
      // no init or update part
      // may as well be: while (true)
    }

  • SuspiciousOctalEscape
    public void foo() {
      System.out.println("suspicious: 128");
      // interpreted as octal 12,
      // followed by character '8'
    }
Epic Evil
PETER KOFLER, CODE-COP.ORG                 FANATIC ABOUT CODE QUALITY




             10 Serious Errors (to fix)
  •    EmptyCatchBlock
  •    ExplicitCallToFinalize
  •    FinalizeDoesNotCallSuperFinalize
  •    FinalizeShouldBeProtected
  •    JUnitSpelling
        – framework methods are easy to misspell
  • JUnitStaticSuite
        – suite() method needs to be public and static
PETER KOFLER, CODE-COP.ORG                FANATIC ABOUT CODE QUALITY




    DoubleCheckedLocking (is broken)
  public Object getInstance() {
    if (inst == null) {        // may be non-null
       synchronized (this) { // yet not fully created
         if (inst == null)
            inst = new Object();
       }
    }
    return inst;
  }
PETER KOFLER, CODE-COP.ORG       FANATIC ABOUT CODE QUALITY




OverrideBothEqualsAndHashcode
   • Override both
     boolean Object.equals(Object o) and
     int Object.hashCode(),
     or override neither.

   • HashMap uses first hashCode() method
     and then equals() method inside the
     hash-bucket...
PETER KOFLER, CODE-COP.ORG           FANATIC ABOUT CODE QUALITY




                Contract of hashCode
  • Same objects must return same integer
  • If two objects are equals(), the
    hashCode() method on each of them
    must produce the same integer.
  • It is not required that if two objects are
    unequal according to the equals(), the
    two objects must produce distinct
    results.
PETER KOFLER, CODE-COP.ORG       FANATIC ABOUT CODE QUALITY




        hashCode Implementation
  private String member;
  public int hashCode() {
    // calculate hashCode from int-values
    // of all members and sum them up
    int result = 17;
    result = 37*result+member.hashCode();
    return result;
  }
PETER KOFLER, CODE-COP.ORG        FANATIC ABOUT CODE QUALITY




     ProperCloneImplementation
  • should be implemented with
    super.clone()

  public Object clone() {
    return new MyClass();    // wrong
  }
PETER KOFLER, CODE-COP.ORG              FANATIC ABOUT CODE QUALITY




                 clone Implementation
  public Object clone() {
    try {
      return super.clone();
    } catch (CloneNotSupportedException e) {
      // should not happen, we are Cloneable
      throw new InternalError(”error in clone");
    }
  }
PETER KOFLER, CODE-COP.ORG            FANATIC ABOUT CODE QUALITY




            ReturnFromFinallyBlock
  public String bugga() {
     try {
        throw new Exception("My Exception");
     } catch (Exception e) {
        throw e;
     } finally {
        return ”O.K.";    // bad
     }
  }
Avoid!
PETER KOFLER, CODE-COP.ORG                        FANATIC ABOUT CODE QUALITY




          More Warnings (to avoid)
  • AvoidCatchingThrowable
        – there will be some exceptions to this rule...
  • ExcessiveClass- & -MethodLength
  • ExcessiveParameterList
  • FinalizeOverloaded
  • SignatureDeclareThrowsException
  • SwitchStmtsShouldHaveDefault
PETER KOFLER, CODE-COP.ORG                 FANATIC ABOUT CODE QUALITY




              ExceptionTypeChecking
  try {
    returnString = sdf.format(value);
  } catch (Exception e) {
    /* BAD STUFF */
    if (e instanceof NumberFormatException)
       System.out.println("NumberFormat!!!");
    if (ex instanceof IllegalArgumentException)
       System.out.println("illegal argument...!!!");
  }
PETER KOFLER, CODE-COP.ORG             FANATIC ABOUT CODE QUALITY



                ConstructorCalls
             OverridableMethodRule
  public class Senior {
   public Senior() {
     toString(); // may throw a NPE if overridden
   }

      public String toString() {
        return "IAmSenior";
      }
  }
PETER KOFLER, CODE-COP.ORG              FANATIC ABOUT CODE QUALITY



            ConstructorCalls
       OverridableMethodRule #2
  public class Junior extends Senior {
    private String name;
    public Junior() {
       super(); // inserted by compiler -> NPE
       name = "JuniorClass";
     }
    public String toString() {
       return name.toUpperCase();
    }
  }
Update
PETER KOFLER, CODE-COP.ORG                  FANATIC ABOUT CODE QUALITY




    Second Iteration (November)
  • Improve quality 
  • 1st iteration removed all 125 errors 
     – 100 seems to be a good work package 
  • In the meantime ...
        – PMD has been updated
        – New rules are available (and in use ;-)
  • Now let’s fix another 8 rules
        – With approx. 100 violations
PETER KOFLER, CODE-COP.ORG                       FANATIC ABOUT CODE QUALITY




                             5 Errors (to fix)
  • AvoidCatchingNPE
  • AvoidThrowingCertainExceptionTypes
  • EmptyStatementNotInLoop
     if (false);
     {
       // will be executed
     }
  • ForLoopsMustUseBraces &
    WhileLoopsMustUseBraces
PETER KOFLER, CODE-COP.ORG               FANATIC ABOUT CODE QUALITY




                       3 Warnings (to fix)
  • BooleanInstantiation
    new Boolean(*)  Boolean.valueOf(*)
  • UnnecessaryReturn
  • UnusedImports – Eclipse warning
PETER KOFLER, CODE-COP.ORG             FANATIC ABOUT CODE QUALITY




          New and Not Triggered #1
  • DontImportSun (not in HP’s JDK)
  • EqualsNull
    if (x.equals(null)) { // never true
  • BrokenNullCheck
    if (s!=null || !s.equals(””)) { // use && !

  • JUnitTestsShouldIncludeAssert
  • TestClassWithoutTestCases
PETER KOFLER, CODE-COP.ORG        FANATIC ABOUT CODE QUALITY




         New and Not Triggered #2
  • SimplifyStartsWith
    startsWith(”a”) charAt(0)=='a'
  • AppendCharacterWithChar
    b.append(”a”) b.append('a')
  • UseIndexOfChar
    s.indexOf(”a”) s.indexOf('a')

  • AvoidProtectedFieldInFinalClass
PETER KOFLER, CODE-COP.ORG     FANATIC ABOUT CODE QUALITY




                             Thank
                              You
PETER KOFLER, CODE-COP.ORG          FANATIC ABOUT CODE QUALITY




                             Peter Kofler

                    @codecopkofler

      www.code-cop.org
PETER KOFLER, CODE-COP.ORG                                FANATIC ABOUT CODE QUALITY




                             CC Images
  •    cleaning: http://www.flickr.com/photos/inf3ktion/4477642894/
  •    agenda: http://www.flickr.com/photos/24293932@N00/2752221871/
  •    micro: http://www.flickr.com/photos/wessexarchaeology/183177852/
  •    trash: http://www.flickr.com/photos/togr/244902037/
  •    building: http://www.flickr.com/photos/stephen_rees/440201126/
  •    evil: http://www.flickr.com/photos/legofenris/4476593087/
  •    avoid: http://www.flickr.com/photos/howardlake/4850758742/
  •    repeat: http://www.flickr.com/photos/cyanocorax/288232991/
  •    questions: http://www.flickr.com/photos/seandreilinger/2326448445/

More Related Content

What's hot

Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014
Andrey Breslav
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 
Ahead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java ApplicationsAhead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java Applications
Nikita Lipsky
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial
garrett honeycutt
 
Con-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With JavassistCon-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With Javassist
Anton Arhipov
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
Min-Yih Hsu
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
Anton Arhipov
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Anton Arhipov
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
Anton Arhipov
 
PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacy
Damien Seguy
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
Damien Seguy
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
 
Testing swagger contracts without contract based testing
Testing swagger contracts without contract based testingTesting swagger contracts without contract based testing
Testing swagger contracts without contract based testing
Алексей Стягайло
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
Matt Butcher
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Mark Niebergall
 
groovy & grails - lecture 5
groovy & grails - lecture 5groovy & grails - lecture 5
groovy & grails - lecture 5
Alexandre Masselot
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
Ortus Solutions, Corp
 
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018
Mark Niebergall
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
Nikita Lipsky
 

What's hot (20)

Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
Ahead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java ApplicationsAhead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java Applications
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
 
20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial
 
Con-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With JavassistCon-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With Javassist
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacy
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Testing swagger contracts without contract based testing
Testing swagger contracts without contract based testingTesting swagger contracts without contract based testing
Testing swagger contracts without contract based testing
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
groovy & grails - lecture 5
groovy & grails - lecture 5groovy & grails - lecture 5
groovy & grails - lecture 5
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
 

Viewers also liked

The headhunters of Love in Finland
The headhunters of Love in FinlandThe headhunters of Love in Finland
The headhunters of Love in Finland
Berkeley International
 
Bab 1-kedudukan
Bab 1-kedudukanBab 1-kedudukan
Bab 1-kedudukan
Zulaikha Imram
 
Wordclases
WordclasesWordclases
Wordclases
Carina Tpt
 
Tugas tik bab 2
Tugas tik bab 2Tugas tik bab 2
Tugas tik bab 2
raninovitasari001
 
Bab 1-kedudukan
Bab 1-kedudukanBab 1-kedudukan
Bab 1-kedudukan
Zulaikha Imram
 
Sistema genesis.2
Sistema genesis.2Sistema genesis.2
Sistema genesis.2
Elyc23
 

Viewers also liked (6)

The headhunters of Love in Finland
The headhunters of Love in FinlandThe headhunters of Love in Finland
The headhunters of Love in Finland
 
Bab 1-kedudukan
Bab 1-kedudukanBab 1-kedudukan
Bab 1-kedudukan
 
Wordclases
WordclasesWordclases
Wordclases
 
Tugas tik bab 2
Tugas tik bab 2Tugas tik bab 2
Tugas tik bab 2
 
Bab 1-kedudukan
Bab 1-kedudukanBab 1-kedudukan
Bab 1-kedudukan
 
Sistema genesis.2
Sistema genesis.2Sistema genesis.2
Sistema genesis.2
 

Similar to Code Quality Assurance with PMD (2004)

Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
Peter Kofler
 
Make static instrumentation great again, High performance fuzzing for Windows...
Make static instrumentation great again, High performance fuzzing for Windows...Make static instrumentation great again, High performance fuzzing for Windows...
Make static instrumentation great again, High performance fuzzing for Windows...
Lucas Leong
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
Peter Kofler
 
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
garrett honeycutt
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
p3castro
 
Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014
dubmun
 
Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)
Peter Kofler
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
CocoaHeads France
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
Peter Kofler
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
Dror Helper
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
Peter Kofler
 
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Theo Jungeblut
 
Writing Better Haskell
Writing Better HaskellWriting Better Haskell
Writing Better Haskell
nkpart
 
Clean Code for East Bay .NET User Group
Clean Code for East Bay .NET User GroupClean Code for East Bay .NET User Group
Clean Code for East Bay .NET User Group
Theo Jungeblut
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023
Scott Keck-Warren
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
Charles Nutter
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Theo Jungeblut
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
ESUG
 

Similar to Code Quality Assurance with PMD (2004) (20)

Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
 
Make static instrumentation great again, High performance fuzzing for Windows...
Make static instrumentation great again, High performance fuzzing for Windows...Make static instrumentation great again, High performance fuzzing for Windows...
Make static instrumentation great again, High performance fuzzing for Windows...
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014
 
Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
 
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
 
Writing Better Haskell
Writing Better HaskellWriting Better Haskell
Writing Better Haskell
 
Clean Code for East Bay .NET User Group
Clean Code for East Bay .NET User GroupClean Code for East Bay .NET User Group
Clean Code for East Bay .NET User Group
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 

More from Peter Kofler

Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
Peter Kofler
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Peter Kofler
 
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Peter Kofler
 
Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)
Peter Kofler
 
Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)
Peter Kofler
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
Peter Kofler
 
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Peter Kofler
 
Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)
Peter Kofler
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
Peter Kofler
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
Peter Kofler
 
Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)
Peter Kofler
 
JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)
Peter Kofler
 
Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)
Peter Kofler
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
Peter Kofler
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
Peter Kofler
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
Peter Kofler
 
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Peter Kofler
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
Peter Kofler
 

More from Peter Kofler (20)

Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
 
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
 
Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)
 
Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
 
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
 
Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
 
Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)
 
JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)
 
Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
 
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
 

Recently uploaded

5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 

Recently uploaded (20)

5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 

Code Quality Assurance with PMD (2004)

  • 1. Code Quality Assurance with PMD (ongoing cleanups) Herold Business Data 2004 to 2006 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.
  • 2. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Peter Kofler • Ph.D. in Applied Math • Professional Software Developer • Developer at Herold Business Data • “fanatic about code quality”
  • 4. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Status Daily Build Static Code Analysis Rule Categorisation Rules to fix/obey ;-)
  • 5. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Daily Build • Since three months • Trunk is compiling (at least more often) – missing files  – shared subproject complexity  • Build history • JavaDoc • XML validation
  • 6. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Next Steps • Static code analysis – check the source • JUnit integration – of few existing tests • Initialise application – integration tests (that would be cool)
  • 8. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY PMD Static Code Analyser • http://pmd.sourceforge.net/ • Scans Java source • JavaCC-generated parser – Abstract Syntax Tree (AST) • Traverses AST • Reports violations
  • 9. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Eclipse Plugin • Install pmd-eclipse2-site-2.0RC3.zip • Patch plugin with current PMD: – extract pmd.jar from pmd-bin-1.5.zip – rename to pmd-1.3.jar and replace in pluginsnet.sourceforge.pmd.core_1.3.2lib • Customise rules: – delete all and import PMD20040427.xml
  • 11. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY “Error” • Really serious errors – e.g. bad practice – or correctness bugs • Currently (only ;-) 125 in whole code base
  • 12. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY “Warning” • Other errors • Currently 4023
  • 13. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY “Info” (Information) • Minor errors – e.g. performance problems • Currently 4091
  • 14. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY “Format” • Formatting Problems – e.g. code style violations • Currently 6834
  • 16. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY “Fix” Process • Activate not (yet) triggered rules – make sure there are no new violations • Fix few “bad guys” first • Activate their rules • Choose next error from list, repeat • In the end only low priority bugs left
  • 17. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Not Triggered Errors • BadComparison if (y == Double.NaN) • EmptyFinalizer • FinalizeOnlyCallsSuperFinalize • FinalizeOverloaded • ShortMethodName (<= 3) • SuspiciousHashcodeMethodName public int hashcode() // <-> hashCode
  • 18. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY • EmptyWhileStmt while (a == b) { // maybe here was some code before } • NonStaticInitializer // public void doSomething() { // this block gets run before any // call to any constructor System.out.println("construct myself"); }
  • 19. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY MethodWithSameName AsEnclosingClass public class MyClass { // bad because it is a method public void MyClass() { } // OK because it is a constructor public MyClass() { } }
  • 20. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY • JumbledIncrementer for (int i = 0; i < 10; i++) { for (int k = 0; k < 20; i++) { System.out.println("Hello"); } } • NonCaseLabelInSwitchStatement switch (a) { case 1 : // do something break; mylabel : // legal but confusing break; }
  • 21. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Not Triggered Warnings • DefaultLabelNotLastInSwitchStmt • DontImportJavaLang • EmptyStaticInitializer • EmptySwitchStatements • EmptySynchronizedBlock • EmptyTryBlock & EmptyFinallyBlock • ImportFromSamePackage
  • 22. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY • ForLoopShouldBeWhileLoop for (; true;) { // no init or update part // may as well be: while (true) } • SuspiciousOctalEscape public void foo() { System.out.println("suspicious: 128"); // interpreted as octal 12, // followed by character '8' }
  • 24. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY 10 Serious Errors (to fix) • EmptyCatchBlock • ExplicitCallToFinalize • FinalizeDoesNotCallSuperFinalize • FinalizeShouldBeProtected • JUnitSpelling – framework methods are easy to misspell • JUnitStaticSuite – suite() method needs to be public and static
  • 25. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY DoubleCheckedLocking (is broken) public Object getInstance() { if (inst == null) { // may be non-null synchronized (this) { // yet not fully created if (inst == null) inst = new Object(); } } return inst; }
  • 26. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY OverrideBothEqualsAndHashcode • Override both boolean Object.equals(Object o) and int Object.hashCode(), or override neither. • HashMap uses first hashCode() method and then equals() method inside the hash-bucket...
  • 27. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Contract of hashCode • Same objects must return same integer • If two objects are equals(), the hashCode() method on each of them must produce the same integer. • It is not required that if two objects are unequal according to the equals(), the two objects must produce distinct results.
  • 28. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY hashCode Implementation private String member; public int hashCode() { // calculate hashCode from int-values // of all members and sum them up int result = 17; result = 37*result+member.hashCode(); return result; }
  • 29. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ProperCloneImplementation • should be implemented with super.clone() public Object clone() { return new MyClass(); // wrong }
  • 30. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY clone Implementation public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { // should not happen, we are Cloneable throw new InternalError(”error in clone"); } }
  • 31. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ReturnFromFinallyBlock public String bugga() { try { throw new Exception("My Exception"); } catch (Exception e) { throw e; } finally { return ”O.K."; // bad } }
  • 33. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY More Warnings (to avoid) • AvoidCatchingThrowable – there will be some exceptions to this rule... • ExcessiveClass- & -MethodLength • ExcessiveParameterList • FinalizeOverloaded • SignatureDeclareThrowsException • SwitchStmtsShouldHaveDefault
  • 34. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ExceptionTypeChecking try { returnString = sdf.format(value); } catch (Exception e) { /* BAD STUFF */ if (e instanceof NumberFormatException) System.out.println("NumberFormat!!!"); if (ex instanceof IllegalArgumentException) System.out.println("illegal argument...!!!"); }
  • 35. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ConstructorCalls OverridableMethodRule public class Senior { public Senior() { toString(); // may throw a NPE if overridden } public String toString() { return "IAmSenior"; } }
  • 36. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ConstructorCalls OverridableMethodRule #2 public class Junior extends Senior { private String name; public Junior() { super(); // inserted by compiler -> NPE name = "JuniorClass"; } public String toString() { return name.toUpperCase(); } }
  • 38. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Second Iteration (November) • Improve quality  • 1st iteration removed all 125 errors  – 100 seems to be a good work package  • In the meantime ... – PMD has been updated – New rules are available (and in use ;-) • Now let’s fix another 8 rules – With approx. 100 violations
  • 39. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY 5 Errors (to fix) • AvoidCatchingNPE • AvoidThrowingCertainExceptionTypes • EmptyStatementNotInLoop if (false); { // will be executed } • ForLoopsMustUseBraces & WhileLoopsMustUseBraces
  • 40. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY 3 Warnings (to fix) • BooleanInstantiation new Boolean(*)  Boolean.valueOf(*) • UnnecessaryReturn • UnusedImports – Eclipse warning
  • 41. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY New and Not Triggered #1 • DontImportSun (not in HP’s JDK) • EqualsNull if (x.equals(null)) { // never true • BrokenNullCheck if (s!=null || !s.equals(””)) { // use && ! • JUnitTestsShouldIncludeAssert • TestClassWithoutTestCases
  • 42. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY New and Not Triggered #2 • SimplifyStartsWith startsWith(”a”) charAt(0)=='a' • AppendCharacterWithChar b.append(”a”) b.append('a') • UseIndexOfChar s.indexOf(”a”) s.indexOf('a') • AvoidProtectedFieldInFinalClass
  • 43. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Thank You
  • 44. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Peter Kofler @codecopkofler www.code-cop.org
  • 45. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY CC Images • cleaning: http://www.flickr.com/photos/inf3ktion/4477642894/ • agenda: http://www.flickr.com/photos/24293932@N00/2752221871/ • micro: http://www.flickr.com/photos/wessexarchaeology/183177852/ • trash: http://www.flickr.com/photos/togr/244902037/ • building: http://www.flickr.com/photos/stephen_rees/440201126/ • evil: http://www.flickr.com/photos/legofenris/4476593087/ • avoid: http://www.flickr.com/photos/howardlake/4850758742/ • repeat: http://www.flickr.com/photos/cyanocorax/288232991/ • questions: http://www.flickr.com/photos/seandreilinger/2326448445/