Re-enable Checkstyle (#10214)

This commit is contained in:
Kris Stern 2025-01-28 04:17:48 +08:00 committed by GitHub
commit deb663ae6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 61 additions and 20 deletions

View File

@ -343,17 +343,20 @@ public class CLI {
class Authenticator extends ClientEndpointConfig.Configurator {
HandshakeResponse hr;
@Override
public void beforeRequest(Map<String, List<String>> headers) {
if (factory.authorization != null) {
headers.put("Authorization", List.of(factory.authorization));
}
}
@Override
public void afterResponse(HandshakeResponse hr) {
this.hr = hr;
}
}
var authenticator = new Authenticator();
ClientManager client = ClientManager.createClient(JdkClientContainer.class.getName()); // ~ ContainerProvider.getWebSocketContainer()

View File

@ -279,7 +279,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
/**
* @deprecated since 2.459 use {@link #createClassLoader(String, List, ClassLoader, Attributes)}
*/
@Deprecated(since="2.459")
@Deprecated(since = "2.459")
protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent, Attributes atts) throws IOException {
// generate a legacy id so at least we can track to something
return createClassLoader("unidentified-" + UUID.randomUUID(), paths, parent, atts);

View File

@ -1115,7 +1115,21 @@ public abstract class Launcher {
final String workDir = psPwd == null ? null : psPwd.getRemote();
try {
RemoteLaunchCallable remote = new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener, ps.stdoutListener, envVarsFilterRuleWrapper);
RemoteLaunchCallable remote = new RemoteLaunchCallable(
ps.commands,
ps.masks,
ps.envs,
in,
ps.reverseStdin,
out,
ps.reverseStdout,
err,
ps.reverseStderr,
ps.quiet,
workDir,
listener,
ps.stdoutListener,
envVarsFilterRuleWrapper);
// reset the rules to prevent build step without rules configuration to re-use those
envVarsFilterRuleWrapper = null;
return new ProcImpl(getChannel().call(remote));

View File

@ -115,8 +115,8 @@ public final class ComputerSet extends AbstractModelObject implements Describabl
}
/**
* @deprecated Use {@link #getComputers()} instead.
* @return All {@link Computer} instances managed by this set.
* @deprecated Use {@link #getComputers()} instead.
*/
@Deprecated(since = "2.480")
public Computer[] get_all() {

View File

@ -354,10 +354,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* Implementation of {@link Job#assignBuildNumber}.
*/
int assignBuildNumber(Job<?, ?> job, SaveNextBuildNumber saveNextBuildNumber) throws IOException;
/**
* Provides an externally accessible alias for {@link Job#saveNextBuildNumber}, which is {@code protected}.
* ({@link #getNextBuildNumber} and {@link #fastUpdateNextBuildNumber} are already accessible.)
*/
interface SaveNextBuildNumber {
void call() throws IOException;
}

View File

@ -117,11 +117,9 @@ public abstract class UserPropertyDescriptor extends Descriptor<UserProperty> {
* Method proposed to prevent plugins to rely on too recent core version
* while keeping the possibility to use the categories.
*
* @deprecated This should only be used when the core requirement is below the version this method was added
*
* @return String name corresponding to the symbol of {@link #getUserPropertyCategory()}
*
* @since 2.468
* @deprecated This should only be used when the core requirement is below the version this method was added
*/
@Deprecated
protected @CheckForNull String getUserPropertyCategoryAsString() {

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -21,8 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.userproperty;
package hudson.model.userproperty;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;

View File

@ -464,7 +464,14 @@ public class RobustReflectionConverter implements Converter {
return context.convertAnother(result, type, converter);
}
private void writeValueToImplicitCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Object value, Map<String, Collection<Object>> implicitCollections, Map<String, Class<?>> implicitCollectionElementTypes, Object result, String itemFieldName) {
private void writeValueToImplicitCollection(
HierarchicalStreamReader reader,
UnmarshallingContext context,
Object value,
Map<String, Collection<Object>> implicitCollections,
Map<String, Class<?>> implicitCollectionElementTypes,
Object result,
String itemFieldName) {
String fieldName = mapper.getFieldNameForItemTypeAndName(context.getRequiredType(), value.getClass(), itemFieldName);
if (fieldName != null) {
Collection collection = implicitCollections.get(fieldName);

View File

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package jenkins.agents;
import edu.umd.cs.findbugs.annotations.NonNull;

View File

@ -185,6 +185,7 @@ public interface IComputer extends AccessControlled, IconSpec {
* Returns the number of {@link IExecutor}s that are doing some work right now.
*/
int countBusy();
/**
* Returns the current size of the executor pool for this computer.
*/
@ -194,6 +195,7 @@ public interface IComputer extends AccessControlled, IconSpec {
* @return true if the computer is online.
*/
boolean isOnline();
/**
* @return the number of {@link IExecutor}s that are idle right now.
*/

View File

@ -113,7 +113,7 @@ public class Nodes implements PersistenceRoot {
* @throws IOException if the new list of nodes could not be persisted.
*/
public void setNodes(final @NonNull Collection<? extends Node> nodes) throws IOException {
Map<String,Node> toRemove = new HashMap<>();
Map<String, Node> toRemove = new HashMap<>();
Queue.withLock(() -> {
toRemove.putAll(Nodes.this.nodes);
for (var node : nodes) {

View File

@ -78,6 +78,7 @@ public class JarURLValidatorImpl extends ChannelConfigurator implements JarURLVa
LOGGER.log(Level.FINE, () -> "Allowing URL: " + url);
}
}
@SuppressFBWarnings(
value = "DMI_COLLECTION_OF_URLS",
justification = "All URLs point to local files, so no DNS lookup.")

View File

@ -197,7 +197,7 @@ public class OperatingSystemEndOfLifeAdminMonitorTest {
* name, and expected value for each of the resource files used by
* the test.
*
* @param simplifyExpectedValue if true, then the expected value
* @param simplify if true, then the expected value
* is simplified by replacing ' ' with '-', by replacing '/' with
* '-', and by removing '(' and ')'.
* @return arguments for ParameterizedTest, resource file name,

View File

@ -375,6 +375,11 @@ THE SOFTWARE.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- Version specified in parent POM -->
</plugin>
</plugins>
</build>

View File

@ -37,7 +37,7 @@ public class UserPropertyTest {
public JenkinsRule j = new JenkinsRule();
public User configRoundtrip(User u) throws Exception {
submit(j.createWebClient().goTo(u.getUrl()+"/account/").getFormByName("config"));
submit(j.createWebClient().goTo(u.getUrl() + "/account/").getFormByName("config"));
return u;
}

View File

@ -164,7 +164,7 @@ public class HudsonPrivateSecurityRealmFIPSTest {
User u1 = securityRealm.createAccount("test", "aValidFipsPass");
WebClient wc = j.createWebClient();
wc.login("test","aValidFipsPass");
wc.login("test", "aValidFipsPass");
HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/");
HtmlPasswordInput password1 = configurePage.getElementByName("user.password");
@ -192,7 +192,7 @@ public class HudsonPrivateSecurityRealmFIPSTest {
WebClient wc = j.createWebClient();
wc.login("test","aValidFipsPass");
wc.login("test", "aValidFipsPass");
HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/");
HtmlPasswordInput password1 = configurePage.getElementByName("user.password");
@ -219,7 +219,7 @@ public class HudsonPrivateSecurityRealmFIPSTest {
User u1 = securityRealm.createAccount("test", "aValidFipsPass");
WebClient wc = j.createWebClient();
wc.login("test","aValidFipsPass");
wc.login("test", "aValidFipsPass");
HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/");
HtmlPasswordInput password1 = configurePage.getElementByName("user.password");

View File

@ -185,7 +185,7 @@ public class FormFieldValidatorTest {
private Secret populatedPassword = Secret.fromString("secret!");
private String textarea;
private Secret emptySecretTextarea;
private Secret populatedSecretTextarea = Secret.fromString("sensitive!");;
private Secret populatedSecretTextarea = Secret.fromString("sensitive!");
@DataBoundConstructor
public ValidatingDescribable() {

View File

@ -307,7 +307,7 @@ public class NodesTest {
private static class DumbSlaveNameAndRemoteFSMatcher extends TypeSafeMatcher<DumbSlavePair> {
private final DumbSlavePair expected;
public DumbSlaveNameAndRemoteFSMatcher(DumbSlavePair expected) {
DumbSlaveNameAndRemoteFSMatcher(DumbSlavePair expected) {
this.expected = expected;
}

View File

@ -156,7 +156,8 @@ public class Security3430Test {
// outdated remoting.jar will fail, but up to date one passes
if (requestingJarFromAgent) {
final IOException ex = assertThrows(IOException.class, () -> channel.preloadJar(j.jenkins.getPluginManager().uberClassLoader, Stapler.class));
assertThat(ex.getMessage(), containsString("No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file."));
assertThat(ex.getMessage(), containsString(
"No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file."));
} else {
assertTrue(channel.preloadJar(j.jenkins.getPluginManager().uberClassLoader, Stapler.class));
assertThat(logRecords.stream().map(LogRecord::getMessage).toList(), is(empty()));
@ -227,7 +228,8 @@ public class Security3430Test {
assertThat(logRecords, not(hasItem(logMessageContainsString("Allowing URL"))));
assertThat(logRecords, hasItem(logMessageContainsString("Rejecting URL: ")));
} else {
assertThat(itex.getCause().getMessage(), containsString("No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file."));
assertThat(itex.getCause().getMessage(), containsString(
"No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file."));
}
}
@ -264,10 +266,11 @@ public class Security3430Test {
private final URL controllerFilePath;
private final String expectedContent;
public Exploit(URL controllerFilePath, String expectedContent) {
Exploit(URL controllerFilePath, String expectedContent) {
this.controllerFilePath = controllerFilePath;
this.expectedContent = expectedContent;
}
@Override
public Void call() throws Exception {
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
@ -290,7 +293,7 @@ public class Security3430Test {
private static final class LogMessageContainsString extends TypeSafeMatcher<LogRecord> {
private final Matcher<String> stringMatcher;
public LogMessageContainsString(Matcher<String> stringMatcher) {
LogMessageContainsString(Matcher<String> stringMatcher) {
this.stringMatcher = stringMatcher;
}