-
Notifications
You must be signed in to change notification settings - Fork 459
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
Enforce var jdk11 applied #1609
base: main
Are you sure you want to change the base?
Changes from all commits
958864d
6e45c6f
53f3fcf
4ee40fd
2fdba8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,10 @@ spotless { | |||||||
java { | ||||||||
ratchetFrom 'origin/main' | ||||||||
bumpThisNumberIfACustomStepChanges(1) | ||||||||
// `setMutators` will discard default mutators | ||||||||
// https://sonarsource.atlassian.net/browse/RSPEC-6212 | ||||||||
cleanthat().version("2.9").sourceCompatibility(project.sourceCompatibility.toString()).clearMutators() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java Lines 376 to 378 in 6789a1d
Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not suceed doing so in the initial iteration. having a new look with your suggestion, I'm still stuck as I can not find Yet, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||
.addMutator('RSPEC-6212') | ||||||||
licenseHeaderFile rootProject.file('gradle/spotless.license') | ||||||||
importOrderFile rootProject.file('gradle/spotless.importorder') | ||||||||
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml') | ||||||||
|
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.
Why wasn't the
URI
above replaced?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.
At first sight, it would be a limitation around type resolution, due to file being processed one a per-file basis. Let me have a deeper look.
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.
UnsolvedSymbolException{context='null', name='BundleException', cause='null'}
. One may argue this information is not relevant in this purpose. However, here it is: JavaParser, the source -> AST used to manipulate Java-Code failed resolving the type ofgetBundleUri(clazz)
as given method refers to a type unknown in the context of given source file.Similar technical challenge around #1379 (comment).
For now, Cleanthat focuses on linting on a per-file basis (for similar reason Spotless processes (for now) each file individually).
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.
Thanks for the explanation!
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 would think that any assignment could be a
var
and we don't need to know anything about its type. The only reason not tovar
is if it's a declaration without an assignment. Am I wrong?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 can find the unitTests for this mutator in LocalVariableTypeInferenceCases. There is multiple cases with
@UnmodifiedMethod
, expressing switching to avar
would be invalid.Even
List<?> i = new ArrayList<String>();
should not be switched tovar
as you may later assign aCopyOnWriteArrayList
whilevar
would have turned semantically fromList
toArrayList
(and you can't assign aCopyOnWriteArrayList
into anArrayList
).We may then suppose
final List<?> i = new ArrayList<String>();
could be turned tovar
, however I may be missing another edge-case, which would lead in Cleanthat producing invalid code.