Skip to content

Remove suppressions for checkstyle MagicNumber #718

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ public DefaultRepositorySystemSession setTransferListener(TransferListener trans
return this;
}

@SuppressWarnings("checkstyle:magicnumber")
private <T> Map<String, T> copySafe(Map<?, ?> table, Class<T> valueType) {
Map<String, T> map;
if (table == null || table.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public void update(String... strings) {
*
* @param chars The characters to update the digest with, may be {@code null}.
*/
@SuppressWarnings("checkstyle:magicnumber")
public void update(char... chars) {
if (chars != null) {
for (char c : chars) {
Expand All @@ -167,7 +166,6 @@ public void update(byte... bytes) {
}
}

@SuppressWarnings("checkstyle:magicnumber")
private String digest() {
byte[] bytes = digest.digest();
StringBuilder buffer = new StringBuilder(bytes.length * 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public void transferCorrupted(TransferEvent event) {
event.getException().printStackTrace(out);
}

@SuppressWarnings("checkstyle:magicnumber")
protected long toKB(long bytes) {
return (bytes + 1023) / 1024;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
@Singleton
@Named(GpgAgentPasswordLoader.NAME)
@Priority(10)
@SuppressWarnings("checkstyle:magicnumber")
public final class GpgAgentPasswordLoader implements GnupgSignatureArtifactGeneratorFactory.Loader {
public static final String NAME = "agent";
private final Logger logger = LoggerFactory.getLogger(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
@Singleton
@Named(GpgConfLoader.NAME)
@Priority(20)
@SuppressWarnings("checkstyle:magicnumber")
public final class GpgConfLoader implements GnupgSignatureArtifactGeneratorFactory.Loader {
public static final String NAME = "conf";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
@Singleton
@Named(GpgEnvLoader.NAME)
@Priority(30)
@SuppressWarnings("checkstyle:magicnumber")
public final class GpgEnvLoader implements GnupgSignatureArtifactGeneratorFactory.Loader {
public static final String NAME = "env";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ private Object getMutex(Path path) {
return path.toAbsolutePath().normalize().toString().intern();
}

@SuppressWarnings({"checkstyle:magicnumber"})
private FileLock fileLock(FileChannel channel, long size, boolean shared) throws IOException {
FileLock lock = null;
for (int attempts = 8; attempts >= 0; attempts--) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public String getEffectiveUpdatePolicy(RepositorySystemSession session, String p
return ordinalOfUpdatePolicy(policy1) < ordinalOfUpdatePolicy(policy2) ? policy1 : policy2;
}

@SuppressWarnings({"checkstyle:magicnumber"})
private int ordinalOfUpdatePolicy(String policy) {
if (RepositoryPolicy.UPDATE_POLICY_DAILY.equals(policy)) {
return 1440;
Expand Down Expand Up @@ -100,7 +99,6 @@ public boolean isUpdatedRequired(RepositorySystemSession session, long lastModif
return checkForUpdates;
}

@SuppressWarnings({"checkstyle:magicnumber"})
private int getMinutes(String policy) {
int minutes;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
*/
final class NodeStack {

@SuppressWarnings({"checkstyle:magicnumber"})
// CHECKSTYLE_OFF: MagicNumber
ArrayList<DependencyNode> nodes = new ArrayList<>(96);
// CHECKSTYLE_ON: MagicNumber

public DependencyNode top() {
if (nodes.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ public CloseableSession build() {
repositorySystemLifecycle);
}

@SuppressWarnings("checkstyle:magicnumber")
private static <T> Map<String, T> copySafe(Map<?, ?> table, Class<T> valueType) {
Map<String, T> map;
if (table == null || table.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
/**
* Common set of tests against Http transporter.
*/
@SuppressWarnings({"checkstyle:MagicNumber", "checkstyle:MethodName"})
@SuppressWarnings({"checkstyle:MethodName"})
public class HttpTransporterTest {

protected static final Path KEY_STORE_PATH = Paths.get("target/keystore");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ private void prepare(HttpUriRequest request, SharingHttpContext context) throws
}
}

@SuppressWarnings("checkstyle:magicnumber")
private void mkdirs(URI uri, SharingHttpContext context) throws Exception {
List<URI> dirs = UriUtils.getDirectories(baseUri, uri);
int index = 0;
Expand Down Expand Up @@ -610,7 +609,6 @@ private <T extends HttpUriRequest> T commonHeaders(T request) {
return request;
}

@SuppressWarnings("checkstyle:magicnumber")
private <T extends HttpUriRequest> void resume(T request, GetTask task) throws IOException {
long resumeOffset = task.getResumeOffset();
if (resumeOffset > 0L && task.getDataPath() != null) {
Expand All @@ -622,7 +620,6 @@ private <T extends HttpUriRequest> void resume(T request, GetTask task) throws I
}
}

@SuppressWarnings("checkstyle:magicnumber")
private void handleStatus(CloseableHttpResponse response) throws Exception {
int status = response.getStatusLine().getStatusCode();
if (status >= 300) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public HttpClientConnectionManager getConnectionManager(ConnMgrConfig config) {
return connectionManagers.computeIfAbsent(config, GlobalState::newConnectionManager);
}

@SuppressWarnings("checkstyle:magicnumber")
public static HttpClientConnectionManager newConnectionManager(ConnMgrConfig connMgrConfig) {
RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ final class SharingAuthCache implements AuthCache {
authSchemes = new HashMap<>();
}

@SuppressWarnings("checkstyle:magicnumber")
private static HttpHost toKey(HttpHost host) {
if (host.getPort() <= 0) {
int port = host.getSchemeName().equalsIgnoreCase("https") ? 443 : 80;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
*
* @since 2.0.0
*/
@SuppressWarnings({"checkstyle:magicnumber"})
final class JdkTransporter extends AbstractTransporter implements HttpTransporter {
private static final Logger LOGGER = LoggerFactory.getLogger(JdkTransporter.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @since 2.0.0
*/
public final class JdkTransporterCloser {
@SuppressWarnings("checkstyle:MagicNumber")

static Runnable closer(HttpClient httpClient) {
return () -> {
if (httpClient instanceof AutoCloseable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* JDK Transporter UT.
*/
@SuppressWarnings({"checkstyle:magicnumber"})
class JdkTransporterTest extends HttpTransporterTest {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class PutTaskRequestContent extends AbstractRequestContent {
private ByteBufferPool bufferPool;
private boolean useDirectByteBuffers = true;

@SuppressWarnings("checkstyle:MagicNumber")
PutTaskRequestContent(PutTask putTask) {
this(putTask, 4096);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ private static Map<String, Object> calc(InputStream data, Collection<String> alg
* @param bytes The bytes to represent in hex notation, may be be {@code null}.
* @return The hexadecimal representation of the input or {@code null} if the input was {@code null}.
*/
@SuppressWarnings("checkstyle:magicnumber")
public static String toHexString(byte[] bytes) {
return StringDigestUtil.toHexString(bytes);
}
Expand All @@ -161,7 +160,6 @@ public static String toHexString(byte[] bytes) {
* @return The byte array of the input or {@code null} if the input was {@code null}.
* @since 1.8.0
*/
@SuppressWarnings("checkstyle:magicnumber")
public static byte[] fromHexString(String hexString) {
return StringDigestUtil.fromHexString(hexString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public static String sha1(final String string) {
* @return The hexadecimal representation of the input or {@code null} if the input was {@code null}.
* @since 2.0.0
*/
@SuppressWarnings("checkstyle:magicnumber")
public static String toHexString(byte[] bytes) {
if (bytes == null) {
return null;
Expand All @@ -115,7 +114,6 @@ public static String toHexString(byte[] bytes) {
* @return The byte array of the input or {@code null} if the input was {@code null}.
* @since 2.0.0
*/
@SuppressWarnings("checkstyle:magicnumber")
public static byte[] fromHexString(String hexString) {
if (hexString == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
class Stack<E> extends AbstractList<E> implements RandomAccess {

@SuppressWarnings("unchecked")
// CHECKSTYLE_OFF: MagicNumber
private E[] elements = (E[]) new Object[96];
// CHECKSTYLE_ON: MagicNumber

private int size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private static char[] copy(char[] chars) {
return (chars != null) ? chars.clone() : null;
}

@SuppressWarnings("checkstyle:magicnumber")
private char[] xor(char[] chars) {
if (chars != null) {
int mask = System.identityHashCode(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public boolean equals(Object obj) {
return ranges.equals(that.ranges);
}

@SuppressWarnings("checkstyle:magicnumber")
@Override
public int hashCode() {
return 97 * ranges.hashCode();
Expand Down