Skip to content

Commit 25344d2

Browse files
committed
[GR-13982] Update mx to make sure we run spotbugs and checkstyle properly
PullRequest: graalpython/412
2 parents bff02ce + f49d7ce commit 25344d2

File tree

50 files changed

+564
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+564
-288
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonLD.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -108,7 +108,8 @@ private void parseOptions(String[] args) {
108108
List<String> bcFiles = searchLib(libraryDirs, arg.substring(2));
109109
for (String bcFile : bcFiles) {
110110
try {
111-
if (Files.probeContentType(Paths.get(bcFile)).contains(LLVM_IR_BITCODE)) {
111+
String contentType = Files.probeContentType(Paths.get(bcFile));
112+
if (contentType != null && contentType.contains(LLVM_IR_BITCODE)) {
112113
logV("library input:", bcFile);
113114
addFile(bcFile);
114115
} else {
@@ -245,7 +246,8 @@ private Collection<? extends String> arMembers(String path) throws IOException,
245246
// seems ok to emulate this at least for the very common case of ar archives with symbol
246247
// definitions that overlap what's defined in explicitly include .o files
247248
outer: for (String f : members) {
248-
if (Files.probeContentType(Paths.get(f)).contains(LLVM_IR_BITCODE)) {
249+
String contentType = Files.probeContentType(Paths.get(f));
250+
if (contentType != null && contentType.contains(LLVM_IR_BITCODE)) {
249251
HashSet<String> definedFuncs = new HashSet<>();
250252
HashSet<String> definedGlobals = new HashSet<>();
251253

graalpython/com.oracle.graal.python.tck/src/com/oracle/graal/python/tck/PythonProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -317,7 +317,7 @@ private static Source createSource(String resourceName) throws IOException {
317317
return Source.newBuilder(ID, in, scriptName).build();
318318
}
319319

320-
private static abstract class PResultVerifier implements ResultVerifier {
320+
private abstract static class PResultVerifier implements ResultVerifier {
321321
}
322322

323323
private static class PSequenceMultiplicationVerifier extends PResultVerifier {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/PythonTests.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public class PythonTests {
7474
}
7575
}
7676

77-
final static ByteArrayOutputStream errArray = new ByteArrayOutputStream();
78-
final static ByteArrayOutputStream outArray = new ByteArrayOutputStream();
79-
final static PrintStream errStream = new PrintStream(errArray);
80-
final static PrintStream outStream = new PrintStream(outArray);
77+
static final ByteArrayOutputStream errArray = new ByteArrayOutputStream();
78+
static final ByteArrayOutputStream outArray = new ByteArrayOutputStream();
79+
static final PrintStream errStream = new PrintStream(errArray);
80+
static final PrintStream outStream = new PrintStream(outArray);
8181

8282
private static Engine engine = Engine.newBuilder().out(PythonTests.outStream).err(PythonTests.errStream).build();
8383
private static Context context = null;
@@ -128,9 +128,9 @@ public static void assertBenchNoError(Path scriptName, String[] args) {
128128
final PrintStream printErrStream = new PrintStream(byteArrayErr);
129129
final PrintStream printOutStream = new PrintStream(byteArrayOut);
130130
File source = getBenchFile(scriptName);
131-
if (args == null)
131+
if (args == null) {
132132
PythonTests.runScript(new String[]{source.toString()}, source, printOutStream, printErrStream);
133-
else {
133+
} else {
134134
args[0] = source.toString();
135135
PythonTests.runScript(args, source, printOutStream, printErrStream);
136136
}
@@ -236,8 +236,9 @@ static void flush(OutputStream out, OutputStream err) {
236236

237237
public static File getBenchFile(Path filename) {
238238
Path path = Paths.get(GraalPythonEnvVars.graalpythonHome(), "benchmarks", "src");
239-
if (!Files.isDirectory(path))
239+
if (!Files.isDirectory(path)) {
240240
throw new RuntimeException("Unable to locate benchmarks/src/");
241+
}
241242

242243
Path fullPath = Paths.get(path.toString(), filename.toString());
243244
if (!Files.isReadable(fullPath)) {
@@ -261,8 +262,9 @@ private static String getFileContent(File file) {
261262
int n = 0;
262263
while (n != -1) {
263264
n = bufferedReader.read(buffer);
264-
if (n != -1)
265+
if (n != -1) {
265266
content.append(buffer, 0, n);
267+
}
266268
}
267269
} finally {
268270
bufferedReader.close();
@@ -307,8 +309,9 @@ public static File getTestFile(Path filename) {
307309
Path path = Paths.get(GraalPythonEnvVars.graalpythonHome(), "com.oracle.graal.python.test", "src", "tests", filename.toString());
308310
if (Files.isReadable(path)) {
309311
return new File(path.toString());
310-
} else
312+
} else {
311313
throw new RuntimeException("Unable to locate " + path);
314+
}
312315
}
313316

314317
public static void runScript(String[] args, File path, OutputStream out, OutputStream err) {
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
3+
4+
<!--
5+
This configuration file was written by the eclipse-cs plugin configuration editor
6+
-->
7+
<!--
8+
Checkstyle-Configuration: Checks
9+
Description: none
10+
-->
11+
<module name="Checker">
12+
<property name="severity" value="error"/>
13+
<module name="TreeWalker">
14+
<module name="AvoidStarImport">
15+
<property name="allowClassImports" value="true"/>
16+
<property name="allowStaticMemberImports" value="true"/>
17+
</module>
18+
<property name="tabWidth" value="4"/>
19+
<module name="LocalFinalVariableName"/>
20+
<module name="LocalVariableName">
21+
<property name="format" value="^(([_a-zA-Z][_a-zA-Z0-9]*$)|(_[A-Z][a-zA-Z0-9]*_[a-z][a-zA-Z0-9]*$))"/>
22+
</module>
23+
<module name="MemberName">
24+
<property name="format" value="^(([_a-zA-Z][_a-zA-Z0-9]*$)|(_[A-Z][a-zA-Z0-9]*_[a-z][a-zA-Z0-9]*$))"/>
25+
</module>
26+
<module name="MethodName">
27+
<property name="format" value="^(([_a-zA-Z][_a-zA-Z0-9]*$)|(_[A-Z][a-zA-Z0-9]*_[a-z][a-zA-Z0-9]*$))"/>
28+
</module>
29+
<module name="PackageName"/>
30+
<module name="ParameterName">
31+
<property name="format" value="^(([_a-zA-Z][_a-zA-Z0-9]*$)|(_[A-Z][a-zA-Z0-9]*_[a-z][a-zA-Z0-9]*$))"/>
32+
</module>
33+
<module name="TypeName">
34+
<property name="format" value="^[_a-zA-Z][_a-zA-Z0-9]*$"/>
35+
</module>
36+
<module name="RedundantImport"/>
37+
<module name="LineLength">
38+
<property name="max" value="255"/>
39+
</module>
40+
<module name="MethodParamPad"/>
41+
<module name="NoWhitespaceAfter">
42+
<property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
43+
</module>
44+
<module name="NoWhitespaceBefore">
45+
<property name="tokens" value="SEMI,DOT,POST_DEC,POST_INC"/>
46+
</module>
47+
<module name="ParenPad"/>
48+
<module name="TypecastParenPad">
49+
<property name="tokens" value="RPAREN,TYPECAST"/>
50+
</module>
51+
<module name="WhitespaceAfter"/>
52+
<module name="WhitespaceAround">
53+
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>
54+
</module>
55+
<module name="AvoidNestedBlocks">
56+
<property name="allowInSwitchCase" value="true"/>
57+
</module>
58+
<module name="EmptyBlock">
59+
<property name="option" value="text"/>
60+
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_TRY,LITERAL_WHILE,STATIC_INIT"/>
61+
</module>
62+
<module name="LeftCurly"/>
63+
<module name="NeedBraces"/>
64+
<module name="RightCurly"/>
65+
<module name="EmptyStatement"/>
66+
<module name="HiddenField">
67+
<property name="severity" value="ignore"/>
68+
<property name="ignoreConstructorParameter" value="true"/>
69+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
70+
</module>
71+
<module name="HideUtilityClassConstructor">
72+
<property name="severity" value="ignore"/>
73+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
74+
</module>
75+
<module name="ArrayTypeStyle"/>
76+
<module name="UpperEll"/>
77+
<module name="FallThrough"/>
78+
<module name="FinalLocalVariable">
79+
<property name="severity" value="ignore"/>
80+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
81+
</module>
82+
<module name="StringLiteralEquality">
83+
<property name="severity" value="error"/>
84+
</module>
85+
<module name="SuperFinalize"/>
86+
<module name="UnnecessaryParentheses">
87+
<property name="severity" value="ignore"/>
88+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
89+
</module>
90+
<module name="Indentation">
91+
<property name="severity" value="ignore"/>
92+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
93+
</module>
94+
<module name="StaticVariableName">
95+
<property name="format" value="^[A-Za-z][a-zA-Z0-9]*$"/>
96+
</module>
97+
<module name="EmptyForInitializerPad"/>
98+
<module name="EmptyForIteratorPad"/>
99+
<module name="ModifierOrder"/>
100+
<module name="DefaultComesLast"/>
101+
<module name="InnerAssignment">
102+
<property name="severity" value="ignore"/>
103+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
104+
</module>
105+
<module name="MutableException">
106+
<property name="severity" value="ignore"/>
107+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
108+
</module>
109+
<module name="ParameterAssignment">
110+
<property name="severity" value="ignore"/>
111+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
112+
</module>
113+
<module name="RegexpSinglelineJava">
114+
<metadata name="net.sf.eclipsecs.core.comment" value="Illegal trailing whitespace(s) at the end of the line."/>
115+
<property name="format" value="\s$"/>
116+
<property name="message" value="Illegal trailing whitespace(s) at the end of the line."/>
117+
<property name="ignoreComments" value="true"/>
118+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Checks for trailing spaces at the end of a line"/>
119+
</module>
120+
<module name="RegexpSinglelineJava">
121+
<metadata name="net.sf.eclipsecs.core.comment" value="illegal space before a comma"/>
122+
<property name="format" value=" ,"/>
123+
<property name="message" value="illegal space before a comma"/>
124+
<property name="ignoreComments" value="true"/>
125+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Checks for whitespace before a comma."/>
126+
<metadata name="com.atlassw.tools.eclipse.checkstyle.customMessage" value="Illegal whitespace before a comma."/>
127+
</module>
128+
<module name="RegexpSinglelineJava">
129+
<property name="format" value="new (Hashtable|Vector|Stack|StringBuffer)[^\w]"/>
130+
<property name="message" value="Don't use old synchronized collection classes"/>
131+
</module>
132+
<module name="SuppressionCommentFilter">
133+
<property name="offCommentFormat" value="Checkstyle: stop constant name check"/>
134+
<property name="onCommentFormat" value="Checkstyle: resume constant name check"/>
135+
<property name="checkFormat" value="ConstantNameCheck"/>
136+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Allow non-conforming constant names"/>
137+
</module>
138+
<module name="SuppressionCommentFilter">
139+
<property name="offCommentFormat" value="Checkstyle: stop method name check"/>
140+
<property name="onCommentFormat" value="Checkstyle: resume method name check"/>
141+
<property name="checkFormat" value="MethodName"/>
142+
<property name="checkC" value="false"/>
143+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable method name checks"/>
144+
</module>
145+
<module name="SuppressionCommentFilter">
146+
<property name="offCommentFormat" value="CheckStyle: stop parameter assignment check"/>
147+
<property name="onCommentFormat" value="CheckStyle: resume parameter assignment check"/>
148+
<property name="checkFormat" value="ParameterAssignment"/>
149+
<property name="checkC" value="false"/>
150+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable Parameter Assignment"/>
151+
</module>
152+
<module name="SuppressionCommentFilter">
153+
<property name="offCommentFormat" value="Checkstyle: stop final variable check"/>
154+
<property name="onCommentFormat" value="Checkstyle: resume final variable check"/>
155+
<property name="checkFormat" value="FinalLocalVariable"/>
156+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable final variable checks"/>
157+
</module>
158+
<module name="SuppressionCommentFilter">
159+
<property name="offCommentFormat" value="CheckStyle: stop inner assignment check"/>
160+
<property name="onCommentFormat" value="CheckStyle: resume inner assignment check"/>
161+
<property name="checkFormat" value="InnerAssignment"/>
162+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable inner assignment checks"/>
163+
</module>
164+
<module name="SuppressionCommentFilter">
165+
<property name="offCommentFormat" value="Checkstyle: stop field name check"/>
166+
<property name="onCommentFormat" value="Checkstyle: resume field name check"/>
167+
<property name="checkFormat" value="MemberName"/>
168+
<property name="checkC" value="false"/>
169+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable field name checks"/>
170+
</module>
171+
<module name="SuppressionCommentFilter">
172+
<property name="offCommentFormat" value="CheckStyle: stop header check"/>
173+
<property name="onCommentFormat" value="CheckStyle: resume header check"/>
174+
<property name="checkFormat" value=".*Header"/>
175+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable header checks"/>
176+
</module>
177+
<module name="SuppressionCommentFilter">
178+
<property name="offCommentFormat" value="CheckStyle: stop line length check"/>
179+
<property name="onCommentFormat" value="CheckStyle: resume line length check"/>
180+
<property name="checkFormat" value="LineLength"/>
181+
</module>
182+
<module name="SuppressionCommentFilter">
183+
<property name="offCommentFormat" value="CheckStyle: start generated"/>
184+
<property name="onCommentFormat" value="CheckStyle: stop generated"/>
185+
<property name="checkFormat" value=".*Name|.*LineLength|.*Header"/>
186+
</module>
187+
</module>
188+
<module name="FileTabCharacter">
189+
<property name="severity" value="error"/>
190+
<property name="fileExtensions" value="java"/>
191+
</module>
192+
<module name="NewlineAtEndOfFile">
193+
<property name="lineSeparator" value="lf"/>
194+
</module>
195+
<module name="Translation"/>
196+
<module name="RegexpMultiline">
197+
<metadata name="net.sf.eclipsecs.core.comment" value="illegal Windows line ending"/>
198+
<property name="format" value="\r\n"/>
199+
<property name="message" value="illegal Windows line ending"/>
200+
</module>
201+
<module name="SuppressWithPlainTextCommentFilter">
202+
<property name="offCommentFormat" value="Checkstyle: stop"/>
203+
<property name="onCommentFormat" value="Checkstyle: resume"/>
204+
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable all checks"/>
205+
</module>
206+
</module>

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonFileDetector.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -47,7 +47,8 @@
4747
public final class PythonFileDetector extends FileTypeDetector {
4848
@Override
4949
public String probeContentType(Path path) throws IOException {
50-
if (path.getFileName().toString().endsWith(".py")) {
50+
Path fileName = path.getFileName();
51+
if (fileName != null && fileName.toString().endsWith(".py")) {
5152
return PythonLanguage.MIME_TYPE;
5253
}
5354
return null;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void initialize(PythonCore core) {
104104

105105
@Builtin(name = "a2b_base64", fixedNumOfPositionalArgs = 1)
106106
@GenerateNodeFactory
107-
static abstract class A2bBase64Node extends PythonUnaryBuiltinNode {
107+
abstract static class A2bBase64Node extends PythonUnaryBuiltinNode {
108108
@Specialization
109109
PBytes doString(String data) {
110110
return factory().createBytes(b64decode(data));
@@ -133,7 +133,7 @@ private byte[] b64decode(byte[] data) {
133133

134134
@Builtin(name = "a2b_hex", fixedNumOfPositionalArgs = 2, declaresExplicitSelf = true)
135135
@GenerateNodeFactory
136-
static abstract class A2bHexNode extends PythonBinaryBuiltinNode {
136+
abstract static class A2bHexNode extends PythonBinaryBuiltinNode {
137137
private ReadAttributeFromObjectNode getAttrNode;
138138

139139
private PException raise(LazyPythonClass klass, String string) {
@@ -178,7 +178,7 @@ private ReadAttributeFromObjectNode getAttrNode() {
178178
@Builtin(name = "b2a_base64", fixedNumOfPositionalArgs = 1, keywordArguments = {"newline"})
179179
@TypeSystemReference(PythonArithmeticTypes.class)
180180
@GenerateNodeFactory
181-
static abstract class B2aBase64Node extends PythonBinaryBuiltinNode {
181+
abstract static class B2aBase64Node extends PythonBinaryBuiltinNode {
182182

183183
@Child private SequenceStorageNodes.ToByteArrayNode toByteArray;
184184
@Child private CastToIntegerFromIntNode castToIntNode;
@@ -298,7 +298,7 @@ PBytes b2sGeneral(Object data, @SuppressWarnings("unused") Object newline) {
298298

299299
@Builtin(name = "b2a_hex", fixedNumOfPositionalArgs = 1)
300300
@GenerateNodeFactory
301-
static abstract class B2aHexNode extends PythonUnaryBuiltinNode {
301+
abstract static class B2aHexNode extends PythonUnaryBuiltinNode {
302302
@Specialization
303303
@TruffleBoundary
304304
String b2a(PBytes data,
@@ -318,7 +318,7 @@ String b2a(PBytes data,
318318

319319
@Builtin(name = "crc32", fixedNumOfPositionalArgs = 1, keywordArguments = "crc")
320320
@GenerateNodeFactory
321-
static abstract class Crc32Node extends PythonBinaryBuiltinNode {
321+
abstract static class Crc32Node extends PythonBinaryBuiltinNode {
322322
@Specialization(guards = "isNoValue(crc)")
323323
@TruffleBoundary
324324
long b2a(PBytes data, @SuppressWarnings("unused") PNone crc,
@@ -332,11 +332,11 @@ long b2a(PBytes data, @SuppressWarnings("unused") PNone crc,
332332

333333
@Builtin(name = "hexlify", fixedNumOfPositionalArgs = 1)
334334
@GenerateNodeFactory
335-
static abstract class HexlifyNode extends B2aHexNode {
335+
abstract static class HexlifyNode extends B2aHexNode {
336336
}
337337

338338
@Builtin(name = "unhexlify", fixedNumOfPositionalArgs = 2, declaresExplicitSelf = true)
339339
@GenerateNodeFactory
340-
static abstract class UnhexlifyNode extends A2bHexNode {
340+
abstract static class UnhexlifyNode extends A2bHexNode {
341341
}
342342
}

0 commit comments

Comments
 (0)