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

Checkstyle: enforce operators' placement in line wraps #319 #382

Merged
merged 1 commit into from May 22, 2017
Merged

Checkstyle: enforce operators' placement in line wraps #319 #382

merged 1 commit into from May 22, 2017

Conversation

eugenepeh
Copy link
Member

Addition to #319
Enhance #368

@mention-bot
Copy link

@eugenepeh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @yl-coder, @damithc and @m133225 to be potential reviewers.

@yamgent
Copy link
Member

yamgent commented May 2, 2017

@eugenepeh Sorry was the PR supposed to be ready? The PR does not have a CanIHasReview posted to it.

@eugenepeh
Copy link
Member Author

@yamgent so sorry was a little busy with finals.
Its not ready yet, there's some error in the build, I will post a CanIHasReview as soon as I fix it.

@CanIHasReview-bot
Copy link

v1

@eugenepeh submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/382/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

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

I can't get this to work on my side. The following errors appear. The errors disappear when I deleted the lines that you added:

Executing external tasks 'checkstyleMain checkstyleTest'...
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:checkstyleMain FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':checkstyleMain'.
> Unable to create a Checker: configLocation {/home/wangleng/github/yamgent/addressbook-level4/config/checkstyle/checkstyle.xml}, classpath {/home/wangleng/github/yamgent/addressbook-level4/build/classes/main:/home/wangleng/github/yamgent/addressbook-level4/build/resources/main}.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.866 secs
The content of element type "module" must match "(module|property|metadata|message)*".
8:24:19 AM: External tasks execution finished 'checkstyleMain checkstyleTest'.

</module>
<module name="OperatorWrap">
<!-- Checks that assign type operator is at the previous end of line in a line wrap.
This include "=", "/=", "+=", "-=", "*=", "%=", ">>=", ">>>=", "<<=", "^=", "&=".
Copy link
Member

Choose a reason for hiding this comment

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

Unless we are using default values (i.e. not specifying the value property manually), the constants ASSIGN, DIV_ASSIGN, etc... seems to be self explanatory. Not sure whether we need to repeat it in the comments in such cases.

Copy link
Member Author

@eugenepeh eugenepeh May 11, 2017

Choose a reason for hiding this comment

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

Ahh... I added them in comments because some values can be hard to understand without referring to the checkstyle documentation. Also, it would be weird to add just some of them, so I added them all. Might need more opinions on this.

P.S
Thanks for testing it on your side because I been trying to resolve this weird error.

@@ -42,7 +42,7 @@ allprojects {
junitVersion = '4.12'
testFxVersion = '4.0.5-alpha'
monocleVersion = '1.8.0_20'
checkstyleVersion = '7.1.2'
checkstyleVersion = '7.2'
Copy link
Member Author

@eugenepeh eugenepeh May 13, 2017

Choose a reason for hiding this comment

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

Discovered that the METHOD_REF token needs checkstyle 7.2 to work,
http://checkstyle.sourceforge.net/releasenotes.html#Release_7.2

Copy link
Member

Choose a reason for hiding this comment

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

Excellent, it works now. 👍

@CanIHasReview-bot
Copy link

v2

@eugenepeh submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/382/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

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

Looks good to me, just minor nit about the spellings in the comments.

@@ -322,6 +322,28 @@
<property name="message" value="Trailing whitespace"/>
</module>

<module name="OperatorWrap">
<!-- Checks that non-assign type operator is at the next line in a line wrap.
Copy link
Member

Choose a reason for hiding this comment

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

assign -> assignment?

<!-- Checks that non-assign type operator is at the next line in a line wrap.
This include "?", ":", "==", "!=", "/", "+", "-", "*", "%", ">>", ">>>",
">=", ">", "<<", "<=", "<", "^", "|", "||", "&", "&&", "instanceof",
"&" when used in a generic upper or lower bounds constrain,
Copy link
Member

Choose a reason for hiding this comment

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

constrain -> constraints?

@CanIHasReview-bot
Copy link

v3

@eugenepeh submitted v3 for review.

(📚 Archive) (📈 Interdiff between v2 and v3)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/382/3/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

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

wraps to follow specific rules, such as having assign operator (=)

The commit message still has the old spelling :P
Should be:

...such as having the assignment operator (=)

@@ -322,6 +322,28 @@
<property name="message" value="Trailing whitespace"/>
</module>

<module name="OperatorWrap">
<!-- Checks that non-assignment type operator is at the next line in a line wrap.
Copy link
Member

Choose a reason for hiding this comment

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

Minor grammar nit:

Checks that the non-assignment...

@@ -322,6 +322,28 @@
<property name="message" value="Trailing whitespace"/>
</module>

<module name="OperatorWrap">
<!-- Checks that non-assignment type operator is at the next line in a line wrap.
This include "?", ":", "==", "!=", "/", "+", "-", "*", "%", ">>", ">>>",
Copy link
Member

Choose a reason for hiding this comment

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

Minor grammar nit:

This includes ...

</module>
<module name="OperatorWrap">
<!-- Checks that assignment type operator is at the previous end of line in a line wrap.
This include "=", "/=", "+=", "-=", "*=", "%=", ">>=", ">>>=", "<<=", "^=", "&=".
Copy link
Member

@yamgent yamgent May 16, 2017

Choose a reason for hiding this comment

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

The grammar nit comments can also be applied here.

@eugenepeh eugenepeh changed the title Checkstyle: enforce operators' placement in line wraps Checkstyle: enforce operators' placement in line wraps #319 May 17, 2017
Our coding standard for Java requires operators' placement in line
wraps to follow specific rules, such as having assignment operator (=)
stay attached to the token that precedes it and having the arithmetric
operator (+) in a new line. These rules are not enforced by
checkstyle.

Let's teach Checkstyle to be stricter about line wrapping around more
symbols by adding the relevant OperatorWrap rules.
@CanIHasReview-bot
Copy link

v4

@eugenepeh submitted v4 for review.

(📚 Archive) (📈 Interdiff between v3 and v4)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/382/4/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

@yamgent yamgent requested review from damithc and chao1995 May 19, 2017 00:23
Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

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

Looks good!

@yamgent yamgent merged commit cc22ed6 into se-edu:master May 22, 2017
@eugenepeh eugenepeh deleted the 319-add-OperatorWrap-rules branch August 18, 2017 08:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants