-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Update Static Analysis #1350
Update Static Analysis #1350
Conversation
So the Issue with Right Curly is that in previous versions of check style it was broken. We use these directive
On Constructors, which means every usage of Since we have decided that this is ok (It's present in dozens of files) I'm going to remove the "CTOR_DEF" check We have a few other instances of methods failing to place their new } on a new line, but only about 4. So I'm going to fix those. |
Remove check for Constructors on a single line, We do this alot Fix several methods without braces on their own lines Fix incorrect indentation in a few files
d9441ae
to
3bc9cd6
Compare
@kbendick I know you were interested in this, you can see from this build a large number of new warnings :) Some I think we can just turn off but I suggest that for this PR we probably just leave warnings as is and fix the warnings in subsequent PR's. cc: @aokolnychyi + @rdblue |
OrElse vs OrElseGet
this.localityPreferred = options.get("locality").map(Boolean::parseBoolean) | ||
.orElse(LOCALITY_WHITELIST_FS.contains(scheme)); | ||
.orElse(localityFallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because schema is non-final we can't just switch this to a lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think actually this would actually be fine, but to make the rules happy we would have to reassign Scheme anyway so I figured we may as well just put the result in a local var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could refactor scheme detection into a method to make scheme effectively final here.
<property name="allowedAnnotations" value="Override, Test"/> | ||
<property name="allowThrowsTagsForSubclasses" value="true"/> | ||
<property name="validateThrows" value="false"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems more general than "allowThrowsTagsForSubclasses"? Are we sure it does the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a complicated story
Long story short, the checks were basically broken in check style so they were removed and are no longer valid configs. We actually don't need to set "validateThrows" to false either since it is false by default. I just wanted to make sure we were aware that we weren't validating any throw related tags.
@@ -347,7 +347,9 @@ public String toString() { | |||
} | |||
|
|||
@Override | |||
public void setBatchSize(int batchSize) {} | |||
public void setBatchSize(int batchSize) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we require the empty line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we actually did for the Private Constructors as well but we were ignoring that everywhere so I deleted that check
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, **METHOD_DEF**, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
Basically Check-style was just broken before (see my comment on this PR) and didn't work correctly on empty blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't suppose it's possible to make it okay to have the right curly on the line just after the method definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is allowed, I'll change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that allow us to turn it back on for private constructors without too much trouble?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to have it on for private constructors and I can change all the references to
private Constructor() {
}
Because I can do that no problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's what we do in most places isn't it? I was hoping that with this update it wouldn't be too many places to change. Probably good to update them to all be standard, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can do that in a separate PR if you want to keep this one small.
@@ -267,7 +267,7 @@ private static TypeDescription buildOrcProjection(Integer fieldId, Type type, bo | |||
// e.g. renaming column c -> d and adding new column d | |||
String name = Optional.ofNullable(mapping.get(nestedField.fieldId())) | |||
.map(OrcField::name) | |||
.orElse(nestedField.name() + "_r" + nestedField.fieldId()); | |||
.orElseGet(() -> nestedField.name() + "_r" + nestedField.fieldId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that it catches these.
Overall, looks good to me. |
Is this still WIP? It looks about ready to me. We can always follow up with more. |
We decided to enforce no single line constructors
Use todoComment rules as a CommentRegex to find comments which lead with a word character. Flags these instances as a mistake.
Updated even more rules, |
Thanks for fixing this, @RussellSpitzer! Really good to have checks working automatically. |
Thanks for reviewing! |
This is an incomplete upgrade but enough to compile the new code and expose the new warnings.
Version Bumps
baseline 0.55 -> 3.36.2
git-version 0.9 -> 0.12.3
Checkstyle Changes Require for Compile
FindBug Suppression Required for Compile
New Checkstyle Violations
New Baseline/Findbug Warnings
@return