Part 5: Enforcing coding standards and best practices process March 2011 Santa Clara Karim DJAAFAR CO of Jasmine Conseil
OBJECTIVES In this fifth part of our trip concerning the management of an agile process in our daily development, we focuses our attention on the quality part of the development Automated testing Automated code quality Build Tool
 
What is CI (Continuous Integration) ? “ Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (includingtest) to detect integration errors as quickly as possible.” Martin Fowler.
Why do we need CI ? Increased productivity Enables shorter feedback cycle when changes are made Code is kept in a “releasable” state Code gets back into the hands of testers quickly Frees the team to do more interesting and valuable work Improves morale, making it easier to retain good developers Enables more frequent releases with new features
Why do we need CI ? Reduced Risk Reduces uncertainty greatly because at all times the team knows what works, what does not, and what the major issues are. Improved quality Makes it easier to find and remove defects because frequent integration and testing identifies bugs as they are introduced. Multi-platform builds help in finding problems that may arise on some, but not all, versions of the supported platform.
A CI scenario starts with the developer committing source code to the repository. On a typical project, people in many project roles may commit changes that trigger a CI cycle: Developers change source code, database administrators (DBAs) change table definitions, build and deployment teams change configuration files, interface teams change DTD/XSD specifications, and so on… Continuous Integration (CI) scenario
The components of a CI system Commit changes Compile Source Code, Integrate Database, Run Tests, Run Inspections, Deploy Software Feedback Mechanism Generate feedback SCM Server (Svn, Git, …) CI Server
Build Tools Automation in a agile scenario CI Build Server Automated testing Automated code quality Build Tool
JASFORGE © PROJECT QUALITY METRIC TOOLS
What is JasForge ? Jasforge is an Open Source project to build a scalable Team collaboration platform for Integrating work across the phases of the development lifecycle Available: Community Edition (Eclipse Public License) Enterprise Edition
JasForge Tools Quality Metric Tools
QUALITY METRIC TOOLS
What is ‘Code quality platform’? A quality platform much manage and covers 7 main axes of code quality: Architecture & Design Comments Coding rules, Potential bugs, Complexity, Unit tests, Duplications.
Why using Quality Metric Tools? Provide quantitative assessment of the source code quality Good indicators of: performance, maintainability, extensibility, reusability Testability  of the application
Software quality metrics Captured during the design or build phase When use QM ?
What is Sonar? “ Sonar is the central place to manage code quality, offering visual reporting on and across projects and enabling to replay the past to follow metrics evolution” source: http://www.sonarsource.org/ http://sonar.codehaus.org/
Sonar: the better quality managment platform Sonar has been a very popular quality management platform. The platform is billed as to continuously analyze and measure the code quality Sonar is an aggregate tool for complex source code management and quality measures It uses : Clover2, Cobertura, PMD, Checkstyle, and Findbugs under the hood. Sonar is a agregate of quality tools which JasForge project natively support to enhance quality process
Sonar features Many l anguages are covered (Java, C, .Net, Flex, PHP, PL/SQL, Cobol, JSP, JSF, Visual Basic 6 Extend ed with plugins All quality in one central place; Web-based application and everything is in 3 clicks;
Build results Code complexity Sonar Features
Code violations Time machine Sonar Features
Sonar : Maven configuration <profile> <id> run-profile </id> <properties> <sonar.jdbc.url> jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8 </sonar.jdbc.url> <sonar.jdbc.driver> com.mysql.jdbc.Driver </sonar.jdbc.driver> <sonar.jdbc.username> sonar </sonar.jdbc.username> <sonar.jdbc.password> s0n4rU53r </sonar.jdbc.password> </properties> </profile>
Sonar How it works ?
SONAR METRICS
Findbugs Findbugs performs static analysis for the Java byte-code to identify software bugs. By providing early feedback about certain (potential) errors in the coding it helps the developer to quickly identify problems in his coding. http://findbugs.sourceforge.net/
Checkstyle Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. http://checkstyle.sourceforge.net/
PMD PMD scans Java source code and looks for potential problems like: Possible bugs - empty try/catch/finally/switch statements Dead code - unused local variables, parameters and private methods Suboptimal code - wasteful String/StringBuffer usage. http://pmd.sourceforge.net/
Corbetura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. http://cobertura.sourceforge.net/ Corbetura
Maven Surefire Plugin The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in 2 different file formats: Plain text files (*.txt) XML files (*.xml)
EXAMPLE: USING CHEKSTYLE PLUGIN IN JASFORGE
Example: Using chekstyle Plugin Quality dashboard
Example: Using chekstyle Plugin List of Rules
Detail of violation Example: Using chekstyle Plugin in Jasforge
Example: Using chekstyle Plugin in Jasforge Code detail :
Demo:
Thank you for your Attention Jasforge: A Jasmine Conseil concept http://www.jasmineconseil.com Need More information ? [email_address] Download the Presentation:

Part5 - enforcing coding standard and best practices with jas forge v1.0

  • 1.
    Part 5: Enforcingcoding standards and best practices process March 2011 Santa Clara Karim DJAAFAR CO of Jasmine Conseil
  • 2.
    OBJECTIVES In thisfifth part of our trip concerning the management of an agile process in our daily development, we focuses our attention on the quality part of the development Automated testing Automated code quality Build Tool
  • 3.
  • 4.
    What is CI(Continuous Integration) ? “ Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (includingtest) to detect integration errors as quickly as possible.” Martin Fowler.
  • 5.
    Why do weneed CI ? Increased productivity Enables shorter feedback cycle when changes are made Code is kept in a “releasable” state Code gets back into the hands of testers quickly Frees the team to do more interesting and valuable work Improves morale, making it easier to retain good developers Enables more frequent releases with new features
  • 6.
    Why do weneed CI ? Reduced Risk Reduces uncertainty greatly because at all times the team knows what works, what does not, and what the major issues are. Improved quality Makes it easier to find and remove defects because frequent integration and testing identifies bugs as they are introduced. Multi-platform builds help in finding problems that may arise on some, but not all, versions of the supported platform.
  • 7.
    A CI scenariostarts with the developer committing source code to the repository. On a typical project, people in many project roles may commit changes that trigger a CI cycle: Developers change source code, database administrators (DBAs) change table definitions, build and deployment teams change configuration files, interface teams change DTD/XSD specifications, and so on… Continuous Integration (CI) scenario
  • 8.
    The components ofa CI system Commit changes Compile Source Code, Integrate Database, Run Tests, Run Inspections, Deploy Software Feedback Mechanism Generate feedback SCM Server (Svn, Git, …) CI Server
  • 9.
    Build Tools Automationin a agile scenario CI Build Server Automated testing Automated code quality Build Tool
  • 10.
    JASFORGE © PROJECT QUALITY METRIC TOOLS
  • 11.
    What is JasForge? Jasforge is an Open Source project to build a scalable Team collaboration platform for Integrating work across the phases of the development lifecycle Available: Community Edition (Eclipse Public License) Enterprise Edition
  • 12.
  • 13.
  • 14.
    What is ‘Codequality platform’? A quality platform much manage and covers 7 main axes of code quality: Architecture & Design Comments Coding rules, Potential bugs, Complexity, Unit tests, Duplications.
  • 15.
    Why using QualityMetric Tools? Provide quantitative assessment of the source code quality Good indicators of: performance, maintainability, extensibility, reusability Testability  of the application
  • 16.
    Software quality metricsCaptured during the design or build phase When use QM ?
  • 17.
    What is Sonar?“ Sonar is the central place to manage code quality, offering visual reporting on and across projects and enabling to replay the past to follow metrics evolution” source: http://www.sonarsource.org/ http://sonar.codehaus.org/
  • 18.
    Sonar: the betterquality managment platform Sonar has been a very popular quality management platform. The platform is billed as to continuously analyze and measure the code quality Sonar is an aggregate tool for complex source code management and quality measures It uses : Clover2, Cobertura, PMD, Checkstyle, and Findbugs under the hood. Sonar is a agregate of quality tools which JasForge project natively support to enhance quality process
  • 19.
    Sonar features Manyl anguages are covered (Java, C, .Net, Flex, PHP, PL/SQL, Cobol, JSP, JSF, Visual Basic 6 Extend ed with plugins All quality in one central place; Web-based application and everything is in 3 clicks;
  • 20.
    Build results Codecomplexity Sonar Features
  • 21.
    Code violations Timemachine Sonar Features
  • 22.
    Sonar : Mavenconfiguration <profile> <id> run-profile </id> <properties> <sonar.jdbc.url> jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8 </sonar.jdbc.url> <sonar.jdbc.driver> com.mysql.jdbc.Driver </sonar.jdbc.driver> <sonar.jdbc.username> sonar </sonar.jdbc.username> <sonar.jdbc.password> s0n4rU53r </sonar.jdbc.password> </properties> </profile>
  • 23.
    Sonar How itworks ?
  • 24.
  • 25.
    Findbugs Findbugs performsstatic analysis for the Java byte-code to identify software bugs. By providing early feedback about certain (potential) errors in the coding it helps the developer to quickly identify problems in his coding. http://findbugs.sourceforge.net/
  • 26.
    Checkstyle Checkstyle isa development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. http://checkstyle.sourceforge.net/
  • 27.
    PMD PMD scansJava source code and looks for potential problems like: Possible bugs - empty try/catch/finally/switch statements Dead code - unused local variables, parameters and private methods Suboptimal code - wasteful String/StringBuffer usage. http://pmd.sourceforge.net/
  • 28.
    Corbetura is afree Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. http://cobertura.sourceforge.net/ Corbetura
  • 29.
    Maven Surefire PluginThe Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in 2 different file formats: Plain text files (*.txt) XML files (*.xml)
  • 30.
    EXAMPLE: USING CHEKSTYLEPLUGIN IN JASFORGE
  • 31.
    Example: Using chekstylePlugin Quality dashboard
  • 32.
    Example: Using chekstylePlugin List of Rules
  • 33.
    Detail of violationExample: Using chekstyle Plugin in Jasforge
  • 34.
    Example: Using chekstylePlugin in Jasforge Code detail :
  • 35.
  • 36.
    Thank you foryour Attention Jasforge: A Jasmine Conseil concept http://www.jasmineconseil.com Need More information ? [email_address] Download the Presentation:

Editor's Notes

  • #9 1. First, a developer commits code to the version control repository. Meanwhile, the CI server on the integration build machine is polling this repository for changes (e.g., every few minutes). 2. Soon after a commit occurs, the CI server detects that changes have occurred in the version control repository, so the CI server retrieves the latest copy of the code from the repository and then executes a build script, which integrates the software. 3. The CI server generates feedback by e-mailing build results to specified project members. 4. The CI server continues to poll for changes in the version control repository.
  • #12 An agile Platform to manage Continuous Integration Process Help development team to better collaborate and be efficient in their daily task (project creation, development, tests, integration, deployment ...)   A central platform for the creation and managing of middle to complex projects, from the inception to the deployment Available in two edition: Community Edition (Eclipse Public License) Enterprise Edition
  • #24 In the previous schema, you can see that the sonar maven plugin rely on other tools: Squid, Cobertura, PMD, etc... This is true for Java analysis and these calls are totally integrated with sonar maven plugin. Such tools exist in the PHP world, and you mave have heard about phpmd, phpdepend, php_codesniffer and phpunit. The Sonar PHP Plugin uses these tools and control them to get the required metrics and to detect violations inside your PHP code and then to insert the collected data inside the Sonar Database. However, for the moment, the integration of such tool is not as smooth as their Java equivalent. So you have to install them manually on your PHP system by following the Sonar PHP Plugin main page. Please stick to the exact required version for each tool.
  • #36 Démo video CreateProject ImportProject