Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Issue #19 Add style checker #20

Merged
merged 3 commits into from Oct 14, 2017

Conversation

MichiruKayo
Copy link
Contributor

--added check style
--fixed check style findings.

--fixed check style findings.
@@ -0,0 +1,109 @@
<?xml version="1.0"?>
Copy link
Contributor

@trioletas trioletas Oct 5, 2017

Choose a reason for hiding this comment

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

that's a lot of style checks..are there any presets available out there that we could simply reference here? just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 2 presets available :
http://checkstyle.sourceforge.net/style_configs.html Google and Sun, will check how to include them by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately it is not possible to have 2 configs . Issue is open in style checker :checkstyle/checkstyle#991

String id;
String joke;
List<String> categories;
private String id;
Copy link
Contributor

Choose a reason for hiding this comment

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

can't say I like this one: who cares if it's not private? It's just a stupid java bean

api/build.gradle Outdated
def dir = "${parent.projectDir}/code-analysis/check-style"
toolVersion = '8.2'
configProperties.configDir = dir
configFile = file("$dir/check-style.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the default file location instead and just drop this line? I would like to reduce boilerplate configs as much as possible, let's stick with convention over configuration as much as possible please

api/build.gradle Outdated
@@ -24,10 +24,30 @@ apply plugin: 'org.springframework.boot'

apply from: 'dotenv.gradle'

apply plugin: 'checkstyle'
apply plugin: 'pmd'
pmdTest.enabled = false
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In tests we usually have hard coded strings/ magic numbers, and style check fails in such case..

Copy link
Contributor

Choose a reason for hiding this comment

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

can we use inline directives to suppress the linting for such cases? tests are also code so we should treat them as such

README.md Outdated

#### IntelliJ

- Edit configurations > "Application" > Add task in "Before launch" section "checkstyleMain pmdMain" and place it as first
Copy link
Contributor

@trioletas trioletas Oct 5, 2017

Choose a reason for hiding this comment

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

is that necessary ? can we just use the plugin and be done with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you start using intellij idea Application run/debug then plugin is not executed.. couldn't find how to force it..

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay let's think about that. But please remove these instructions from the documentation. its unnecessarily cumbersome

README.md Outdated

- Edit configurations > "Application" > Add task in "Before launch" section "checkstyleMain pmdMain" and place it as first
- Additionally you can download "CheckStyle plugin". Then open Settings > Other Settings > Checkstyle. Add path to check-style.xml file
and provide link to check-style folder in "${configDir}". This will display errors in editor, but it wont affect build/run.
Copy link
Contributor

@trioletas trioletas Oct 5, 2017

Choose a reason for hiding this comment

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

but it won affect build/run

sounds fine by me :) who doesn't love the local build failing due to a missing private modifier?

README.md Outdated

#### Gradle

- As default behaviour it is configured to call "checkstyleMain pmdMain" before "bootRun" task is executed
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I like this one, it basically stops me from launching the dev mode unless all my modifiers are private and stuff.. Can we relax this one?

api/build.gradle Outdated
toolVersion = '8.2'
configProperties.configDir = dir
configFile = file("$dir/check-style.xml")
sourceSets = [] // used to skip tests
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

api/build.gradle Outdated
pmd {
toolVersion = '5.8.1'
consoleOutput = true
ruleSetFiles = files("${parent.projectDir}/code-analysis/pmd/pmd.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do a convention over configuration with this one as well. I do recall there being a default directory where pmd looks for its configs

</module>

<module name="Header">
<property name="header" value="Copyright Swiss Reinsurance Company, Mythenquai 50/60, CH 8022 Zurich. All rights reserved."/>
Copy link
Contributor

Choose a reason for hiding this comment

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

oops you did it again

please be careful with this stuff

"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<!--Add exclusion here (e.g <suppress files="JokeResolver.java" checks="MethodLength"/>) -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we trying to teach how to use check-style here? Please drop all unnecessary config files, thanks!

--removed pmd (only 1 check is really needed, not worth adding by default)
--cleanup of checks
--updated readme
@MichiruKayo
Copy link
Contributor Author

MichiruKayo commented Oct 6, 2017

1: Removed pmd checks (not worth it)
2: Based on default checks, reviewed them and removed ones i think are not needed
3: updated read.me
4: config location is required. Default path is <build.gradle.folder>/config/stylecheck/stylecheck.xml, in our case it is api/config/... , dont think adding such folder is good.. maybe better to change it to root build.gradle? ( but i do not know how to configure that)
5: Changed dependendOn to "build" will probably be called during deployment?.. not sure where to attach it, since we do not have many tasks..

@trioletas
Copy link
Contributor

trioletas commented Oct 7, 2017

4: config location is required. Default path is <build.gradle.folder>/config/stylecheck/stylecheck.xml, > in our case it is api/config/... , dont think adding such folder is good.. maybe better to change it to > > root build.gradle? ( but i do not know how to configure that)

I do not see a problem with the api/config folder. It is a configuration for the api module is it not?

@MichiruKayo
Copy link
Contributor Author

Changed to default location as we discussed offline

@trioletas
Copy link
Contributor

Thanks, looks good to me.
@sergeytrasko any comments from your side? Otherwise we're good to go.

@trioletas trioletas merged commit dd499a0 into ctco:master Oct 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants