-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
IntelliJ/Java: Duplicate code -- Refactored as UnstableAwareCommandInterpreter.helpCheckUnstableReturn #4077
Conversation
…terpreter.helpCheckUnstableReturn
} | ||
|
||
public boolean isApplicable(Class<? extends AbstractProject> jobType) { | ||
return true; | ||
} | ||
} | ||
|
||
static String invalidExitCodeZero() { |
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.
Need to remove this strategy as it won't do what I want, per #4034 (comment)
super(command); | ||
} | ||
|
||
static String invalidExitCodeZero() { return null; }; |
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 they need to be static?
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.
The problem is that the caller is:
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
...
public FormValidation doCheckUnstableReturn(@QueryParameter String value) {
return helpCheckUnstableReturn(value);
I'm not sure how to get past this. I guess the way to do it is to pass an object to helpCheckUnstableReturn
if (unstableReturn == 0) { | ||
return FormValidation.warning(invalidExitCodeZero()); | ||
} | ||
if (unstableReturn < 1 || unstableReturn > 255) { |
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.
The code in BatchFile uses Integer.MIN_VALUE and Integer.MAX_VALUE so this would be changing the behaviour.
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.
Good catch.
return FormValidation.error(hudson.tasks.Messages.Shell_invalid_exit_code_range(unstableReturn)); | ||
} | ||
return FormValidation.ok(); | ||
public static FormValidation doCheckUnstableReturn(@QueryParameter String value) { |
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'm not sure making it public is safe and backward compatible.
return FormValidation.error(hudson.tasks.Messages.BatchFile_invalid_exit_code_range(unstableReturn)); | ||
} | ||
return FormValidation.ok(); | ||
static public FormValidation doCheckUnstableReturn(@QueryParameter String value) { |
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 are we investing time in improving a method that shouldn't be used?:
@Restricted(DoNotUse.class)
This type, field, or method shall never be referenced from anywhere at all.
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.
FTR the @Restricted(DoNotUse.class)
is meant for Jelly calls. It's a method that is called by Stapler, detected using reflection during the form build process.
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.
Are you sure? I think it's used to warn programmers
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.
Although the improvements are good, my feeling is that we don't need to improve it because we are breaking the API and the methods shouldn't be used. So my proposal is to close this PR unless the API changes are reverted. Anyway, thanks Jsoref for your work. |
I'm closing this given there's been no activity for some time. Please feel free to reopen if you plan to work on this again. |
This is for discussion.
Notes:
Proposed changelog entries
Internal:
Internal Java code cleanupSubmitter checklist
* Use the
Internal:
prefix if the change has no user-visible impact (API, test frameworks, etc.)Desired reviewers
@Wadeck