Monday, December 15, 2014

Sonarqube t-shirt for valuable rule

I got t-shirt for idea for static code analysis
http://www.sonarqube.org/suggest-a-valuable-rule-win-a-sonarqubet-shirt/
http://jira.sonarsource.com/browse/RSPEC-2212
https://github.com/checkstyle/checkstyle/issues/141

you can do that to






Wednesday, December 3, 2014

Checkstyle GSOC 2014 results


Checkstyle is a development tool which helps Java programmers to write a code that adheres to specific coding standards. This summer our organization participated in GSoC for the first time. Our main idea for GSOC 2014 was to improve Checkstyle ANTLR grammar in order to support Java 8 syntax changes. The next idea was to allow Checkstyle to validate comments and JavaDoc blocks in sources. And the last, we wanted to create Checkstyle config which covers Google’s style guide for Java that would come with Checkstyle distribution. GSoC has offered three student slots, which allowed us to realize our exciting ideas this summer.

ANTLR grammar for Java 8 features  -- Student: Ilja Dubinin


Java 8 is already released , but users who rely on Checkstyle to enforce code standards(style) can not use Java 8 features as Checkstyle is crashing on lambda and default methods appearance. This forces users to choose between using either Java 8 or Checkstyle. Some organizations enforce code standard adherence even on commit hook that makes choice even more acute.
Ilja made it possible to use Checkstyle on Java 8 specific sources. His work did not involve massive coding, however but he did a detailed investigation of all aspects and usages of new Java 8 features. He analyzed massive java grammar and found places where update is essential and performed it without damaging any other parsing features. He did massive testing on open-source projects that already use Java 8 features, one of the examples is reported on openjdk.
My best experience from working with Ilja was that he did most of development without mentor supervision , and he always reported results on time.

By Roman Ivanov, Checkstyle Mentor



ANTLR grammar for comments and Documentation comments (JavaDocs)  -- Student: Baratali Izmailov


    Completion of this project  will allow Java developer to validate their JavaDoc to comply with  specific style guide by Checkstyle. In addition to non configurable JDK DocLint feature that is appeared in Java 8, Checkstyle allows developers to write their own complicated validation rules(example) for JavaDoc and comments easily. This task was divided in 2 parts:  
1. Add to internally created parse tree single-line and multiline comments
2. Add grammar based parser for JavaDoc comments that is a special format of multiline comment.
    For (1) Baratali updated existing Checkstyle ANTLR grammar while for (2) he wrote the separate ANTLR4 grammar and parsing processor which supports standard and custom JavaDoc tags and JavaDoc html4 formatting.
No significant changes were made to Checkstyle API. API update is absolutely compatible, no changes in any existing Checks are required. Comments could be available in parse tree only when Check require comments.
Baratali tested his code by writing UTs and running updated Checkstyle on openjdk8, spring, guava and some another huge opensource projects.

By Daniil Yaroslavtsev and Roman Ivanov, Checkstyle Mentors



Checkstyle configuration for “Google Java Style” guide  -- Student: Maxim Vetrenko

“Google Java Style” guide is the second most popular guide among the open source community. Finally it can be applied and used in projects a lot more easier with the aid of Maxim’s work. If you do not know what style to use or do not want to invent your own style - just use Google’s code standard, as it is proven style from prominent developers.
The main goal of the project was to review requirements of Google’s Java Code Style and to create a Checkstyle configuration for all rules of that guide that could be validated automatically.
The main problem was to instill in student mind best practices of development process. Changing student’s “I will code right away” approach to the “I will understand the problem, ask questions, write tests first, slice and dice big task in small sub-tasks and only then code the program” approach. This led to the “every day” communication practice which played a key role in finishing the project successfully.
Created configuration was tested on Guava Google Core Libraries for Java, final report is here. Detailed Checkstyle coverage report for Google Style is located here.

By Ruslan Diachenko and Roman Ivanov, Checkstyle Mentor
s



We are pleased to announce that Checkstyle had 3 students who successfully complete at their first  year Google Summer of Code program. If you would like to read more about the work students completed on Checkstyle, during this year’s program, you can check out our mailing list posts or twitter.

By Roman Ivanov Checkstyle Organization Administrator for Google Summer of Code

Tuesday, November 18, 2014

Excessive use of Guava's functional programming

https://code.google.com/p/guava-libraries/wiki/FunctionalExplained

Excellent to my mind ! Common sense should win functional craziness.

Excessive use of Guava's functional programming idioms can lead to verbose, confusing, unreadable, and inefficient code. These are by far the most easily (and most commonly) abused parts of Guava, and when you go to preposterous lengths to make your code "a one-liner," the Guava team weeps.

Imperative code should be your default, your first choice as of Java 7.

Saturday, November 1, 2014

Sync Eclipse workspace settings in sync

Looks like my wishes for Eclipse like :
- Setting workspace preferences.
- Configuring dynamic working sets.
- Keeping project preferences files in sync.

implemented in following project: https://wiki.eclipse.org/Eclipse_Oomph_Installer

Wednesday, October 22, 2014

How to use snapshot checkstyle version in maven plugin

Base on knowledge from http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-developed-checkstyle.html#Configure_the_Checkstyle_Plugin_to_use_your_custom_checks

you can easily force to maven checkstyle plugin to use custom/snapshot/different version of Checkstyle library.
It is very useful for testing of new Checks and generating HTML report on big sources on checkstyle library that you want and not a default old Checkstyle version that is attached to plugin.

<project>
...
  <build>
    <pluginManagement>
      <plugins>
....
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-checkstyle-plugin</artifactId>
     <version>2.13</version>
     <dependencies>
       <dependency>
   <groupId>com.puppycrawl.tools</groupId>
         <artifactId>checkstyle</artifactId>
          <version>6.2-SNAPSHOT</version>
       </dependency>
     </dependencies>
        <configuration>
          <configLocation>my_checkstyle.xml</configLocation>
          <enableFilesSummary>false</enableFilesSummary>
        </configuration>
   </plugin>        
.....
      </plugins>
    </pluginManagement>
  </build>
......
  <reporting>
    <plugins>
     <!-- that plugin is required to link violation with source code, without that plugin report is useless and hard to use -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>2.4</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.13</version>
<!-- Specifying configuration here will take effect on the execution of "mvn site",
          but will not take effect on the execution of "mvn checkstyle:checkstyle"  -->
<configuration>
           <configLocation>checkstyle.xml</configLocation>
            <failOnViolation>false</failOnViolation>
            <enableFilesSummary>false</enableFilesSummary>
</configuration>
      </plugin>
    </plugins>
  </reporting>
....
</project>

Build HTML report by "mvn site" command, or "mvn checkstyle:checkstyle".

to have different HTML reports (for each tested Check) over the same sources - just save index.html as index-MyCheck.html, and do report generation for each Check separately.

Tuesday, October 14, 2014

Sevntu Checkstyle release 1.12.0

new release of Checkstyle extension (Sevntu.Checkstyle) 1.12.0, with new checks:
DiamondOperatorForVariableDefinitionCheck,
PublicReferenceToPrivateTypeCheck,
TernaryPerExpressionCountCheck

Updates in:
RedundantReturnCheck
CustomDeclarationOrderCheck
LineLengthCheck
ForbidThrowAnonymousExceptionsCheck,

Details:
http://daniilyar.blogspot.com/2014/10/sevntu-checkstyle-release-112-checks.html