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
walkmod execution to remove dead code #1957
Conversation
👎 even if classes are not marked with |
Thank you for your comments
|
Sorry, i wasn't clear enough.
|
I'm not yet sure if I think this is a good thing or not, but its an interesting idea! |
@imod @oleg-nenashev and i do periodic static analysing verifications with coverity (that is the most powerful as it closed source). Code styling under discussion. Dependency changes under question as it may change versions and break plugins. PR build fails because of license(?). |
Probably needs to be added to https://github.com/jenkinsci/jenkins/blob/master/licenseCompleter.groovy |
Thank your for all your comments :) I really appreciate them.
|
Hi, I have upgraded the walkmod configuration and the final result. Now, the readResolve methods are not removed. Can you take a look if the rest is ok for you? Thanks |
/** | ||
* Lazily computed set of labels from {@link #label}. | ||
*/ | ||
private transient volatile Set<Label> labels; |
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.
Should be protected instead of private. But probably may cause compatibility issues.
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.
Perfect :-) ! I can 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.
I fear you can't touch it because it may cause issues as i definitely remember that using labels cache for slaves. Feel free to investigate cloud plugins.
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.
Jenkins allow that cloud plugins are able to access to this "private" field using reflection? Otherwise, they can't access to this field.
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.
java code - not, groovy - whatever you want.
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.
Ok ok, thanks
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 have found plugins with groovy code that reference this property. I will add an exclude rule to avoid remove this property.
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.
@rpau and now image that not all plugins under jenkinsci github account are hosted. Any clean-up change adds probability in compatibility breakage that jenkins is keeping so many years. You can propose such step for 2.0 as it will expect breakages. Removing unused imports imho relates to coding style (thread that i started in dev list).
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.
Yes, I understand it, but I think that it is consequence of a direct binding of the plugins with the internal implementation details. I agree on applying these kind of changes in the 2.0 version.
Removing unused imports or variables is part of the coding style, but also any of the changes in the Java source file as well. However, in contrast with the field and method declarations, it can't break plugins.
Any removed method can be accessed from groovy. |
Could you provide diff of dependencies before this PR and after? |
So,
|
Wait for other reviewers. Keeping in mind that some of already on vacation, it may happen that PR wouldn't be merged until january.
|
Diff It includes the new runtime dependency (javarebel-sdk) and the excluded rules for stappler that previously, sends a conflict message.
|
@@ -674,7 +674,7 @@ public void renameTo(String newName) throws IOException { | |||
|
|||
@Override | |||
public void movedTo(DirectlyModifiableTopLevelItemGroup destination, AbstractItem newItem, File destDir) throws IOException { | |||
Job newJob = (Job) newItem; // Missing covariant parameters type here. |
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 thought this comment was related to removed line. I guess it used to check types even if it not used.
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 do you think that is makes sense if the parameter is not used?
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 see any reason to keep this 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.
Or to be on the safe side assert newItem instanceof Job
<artifactId>javarebel-sdk</artifactId> | ||
<version>2.0.2</version> | ||
<scope>runtime</scope> | ||
</dependency> |
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.
CC @bsideup
WDYM? (Is this comment obsolete?) |
Hi, is going to be accepted this pull request? What else is necessary to correct? Thanks |
@rpau get agreement between contributors, that may end in PR delayed for years. |
Not really, but i'm against removing some code just for analyser until core will have some defined rules. I also don't think that @rpau would be ready to work on any regressions caused but this changes. Also this PR still doesn't pass verification. |
@@ -44,4 +44,3 @@ | |||
*/ | |||
package hudson.init; | |||
|
|||
import org.jvnet.hudson.reactor.Task; |
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.
Is javadoc navigable after this change?
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.
Yes, because the javadoc only uses a full qualified name
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.
Not all docs using FQDN that depends on IDE settings.
@KostyaSha Any Groovy script wasn't supposed to access private methods in the first place. There has never been a reasonable expectation that we keep compatibility for those. |
Any plans to finalize it? |
@oleg-nenashev To finalize the review? |
PR appears to have been abandoned, closing. |
Hi,
I have executed walkmod, an open source tool to apply code conventions. In this case, I just tried to remove dead code in the core module. After executing it, the results are as follows:
Moreover, executing walkmod I have discovered some dependency conflicts that I have specified as "exclusions" and a missing runtime dependency.
Let me know if the results seem interesting to you :) and thank you for your time.