Skip to content

1.x: Add PMD code checking tool to the build process #4068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 22, 2016

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Jun 22, 2016

This PR adds a PMD plugin to the build process to check a set of coding rules.

At this point, I don't think rule violations should fail the build.

Unfortunately, I don't know about a service, like codecov-io, that could post the check results as comments under a PR, therefore, the current build just prints the first ~100 violations into the build log:

https://travis-ci.org/ReactiveX/RxJava/builds/139539158#L240

https://travis-ci.org/ReactiveX/RxJava/builds/139539158#L5508

@codecov-io
Copy link

codecov-io commented Jun 22, 2016

Current coverage is 80.62%

Merging #4068 into 1.x will increase coverage by 0.07%

@@                1.x      #4068   diff @@
==========================================
  Files           254        254          
  Lines         16538      16538          
  Methods           0          0          
  Messages          0          0          
  Branches       2510       2510          
==========================================
+ Hits          13322      13334    +12   
+ Misses         2332       2323     -9   
+ Partials        884        881     -3   

Powered by Codecov. Last updated by d477f9c...b67b5c8

@akarnokd akarnokd mentioned this pull request Jun 22, 2016
@akarnokd akarnokd changed the title 1.x: Run PMD, cat its result xml 1.x: Add PMD code checking tool to the build process Jun 22, 2016
@akarnokd akarnokd added the Build label Jun 22, 2016
@akarnokd
Copy link
Member Author

@artem-zinnatullin @zsxwing your thoughts on this?

}
}

build.dependsOn 'pmd'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this since in the bottom you have build.dependsOn 'pmdPrint' which includes pmd as far as I understand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it this way in case the pmdPrint gets replaced with a better feedback mechanisms and the dependency chain won't get broken easily.

@artem-zinnatullin
Copy link
Contributor

👍

ruleSetFiles = files('pmd.xml')
}

task('pmd', type: Pmd, dependsOn: 'assemble') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task is not necessary. Do you want a task to run manually? If so, just run ./gradlew pmdMain.

@zsxwing
Copy link
Member

zsxwing commented Jun 22, 2016

Just some minor issues. Otherwise, 👍

@akarnokd
Copy link
Member Author

Updated.

}
}

build.dependsOn pmdMain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: this line is not necessary because of the task dependency chain: build -> check -> pmdMain

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, would you like to post a PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. See #4086

@akarnokd akarnokd merged commit 544690b into ReactiveX:1.x Jun 22, 2016
@akarnokd akarnokd deleted the PMD branch June 22, 2016 20:42
<description>RxJava PMD ruleset</description>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod"/>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod"/>
<rule ref="rulesets/java/design.xml/AccessorClassGeneration"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

Now why don't they have an AccessorMethodGeneration check as well?!?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, it's not in their design.xml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanniktech
Copy link
Collaborator

Should PMD also be added to the 2.x branch? The earlier it's added the earlier warnings could be fixed.

@akarnokd
Copy link
Member Author

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants