Skip to content

Commit

Permalink
[checkstyle] Improved validation scope of MagicNumber (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashulin authored Jul 19, 2022
1 parent dda2bb7 commit 6d08b5f
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public boolean equals(Object o) {
return tableId == that.tableId && kind == that.kind && Arrays.deepEquals(fields, that.fields);
}

@SuppressWarnings("magicnumber")
@Override
public int hashCode() {
int result = Objects.hash(tableId, kind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public boolean equals(Object obj) {
}

@Override
@SuppressWarnings("MagicNumber")
public int hashCode() {
int result = Arrays.hashCode(fieldNames);
result = 31 * result + Arrays.hashCode(fieldTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

public class VariablesSubstituteTest {

@SuppressWarnings("checkstyle:MagicNumber")
@Test
public void testSubstitute() {
String timeFormat = "yyyyMMddHHmmss";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.util.List;

@SuppressWarnings("magicnumber")
public class AssertExecutorTest extends TestCase {
SeaTunnelRow row = new SeaTunnelRow(new Object[]{"jared", 17});
SeaTunnelRowType rowType = new SeaTunnelRowType(new String[]{"name", "age"}, new SeaTunnelDataType[]{BasicType.STRING_TYPE, BasicType.INT_TYPE});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import java.util.List;

@SuppressWarnings("magicnumber")
public class AssertRuleParserTest extends TestCase {
AssertRuleParser parser = new AssertRuleParser();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testCommit() throws Exception {
Assert.assertTrue(!HdfsUtils.fileExist(transactionDir));
}

@SuppressWarnings({"checkstyle:MagicNumber", "checkstyle:UnnecessaryParentheses"})
@SuppressWarnings("checkstyle:UnnecessaryParentheses")
@Test
public void testCombine() throws Exception {
FileSinkAggregatedCommitter fileSinkAggregatedCommitter = new FileSinkAggregatedCommitter(new HdfsFileSystemCommitter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testCommit() throws Exception {
Assert.assertTrue(!FileUtils.fileExist(transactionDir));
}

@SuppressWarnings({"checkstyle:UnnecessaryParentheses", "checkstyle:MagicNumber"})
@SuppressWarnings("checkstyle:UnnecessaryParentheses")
@Test
public void testCombine() throws Exception {
FileSinkAggregatedCommitter fileSinkAggregatedCommitter = new FileSinkAggregatedCommitter(new LocalFileSystemCommitter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.List;

@SuppressWarnings("magicnumber")
public class AssertExecutorTest extends TestCase {
Row row = Row.withNames();
AssertExecutor assertExecutor = new AssertExecutor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.util.List;

@SuppressWarnings("magicnumber")
public class AssertRuleParserTest extends TestCase {
AssertRuleParser parser = new AssertRuleParser();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public boolean equals(Object o) {
}

@Override
@SuppressWarnings("magicnumber")
public int hashCode() {
if (hashCode != -1) {
return hashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public boolean equals(Object o) {
}

@Override
@SuppressWarnings("magicnumber")
public int hashCode() {
int result = shardKey.hashCode();
result = 31 * result + shardKeyType.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
public class FakeSourceToConsoleIT extends FlinkContainer {

@Test
@SuppressWarnings("magicnumber")
public void testFakeSourceToConsoleSink() throws IOException, InterruptedException {
Container.ExecResult execResult = executeSeaTunnelFlinkJob("/fake/fakesource_to_console.conf");
Assert.assertEquals(0, execResult.getExitCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class FakeSourceToClickhouseIT extends FlinkContainer {
private static final Logger LOGGER = LoggerFactory.getLogger(FakeSourceToClickhouseIT.class);

@Before
@SuppressWarnings("magicnumber")
public void startClickhouseContainer() throws InterruptedException {
clickhouseServer = new GenericContainer<>(CLICKHOUSE_DOCKER_IMAGE)
.withNetwork(NETWORK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
public class FakeSourceToConsoleIT extends SparkContainer {

@Test
@SuppressWarnings("magicnumber")
public void testFakeSourceToConsoleSine() throws IOException, InterruptedException {
Container.ExecResult execResult = executeSeaTunnelSparkJob("/fake/fakesource_to_console.conf");
Assert.assertEquals(0, execResult.getExitCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
public class FakeSourceToFileIT extends SparkContainer {

@Test
@SuppressWarnings("magicnumber")
public void testFakeSourceToFile() throws IOException, InterruptedException {
Container.ExecResult execResult = executeSeaTunnelSparkJob("/file/fakesource_to_file.conf");
Assert.assertEquals(0, execResult.getExitCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public boolean equals(Object o) {
}

@Override
@SuppressWarnings("checkstyle:magicnumber")
public int hashCode() {
int result = engineType != null ? engineType.hashCode() : 0;
result = 31 * result + (pluginType != null ? pluginType.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void convertShortType() {
}

@Test
@SuppressWarnings("MagicNumber")
public void convertBigDecimalType() {
Assert.assertEquals(new BigDecimalTypeInfo(30, 2), TypeConverterUtils.convert(new DecimalType(30, 2)));
}
Expand Down
9 changes: 8 additions & 1 deletion tools/checkstyle/checkStyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="SuppressionSingleFilter">
<property name="files" value=".*(IT|Test).java"/>
<property name="checks" value="MagicNumber"/>
</module>

<module name="SuppressWarningsFilter"/>
<module name="TreeWalker">
<module name="SuppressWarningsHolder"/>
Expand Down Expand Up @@ -207,7 +212,9 @@

<module name="OneStatementPerLine"/>

<module name="MagicNumber"/>
<module name="MagicNumber">
<property name="ignoreHashCodeMethod" value="true"/>
</module>

<module name="MultipleVariableDeclarations"/>

Expand Down

0 comments on commit 6d08b5f

Please sign in to comment.