Skip to content

Commit

Permalink
Removed the "LineLength" check, and all related "// SUPPRESS CHECKSTY…
Browse files Browse the repository at this point in the history
…LE LineLength:xx" event suppression comments - mostly because suppression of that event stopped working in a recent CheckStyle version, and also because checking line lengths is mostly unnecessary.
  • Loading branch information
aunkrig committed May 19, 2022
1 parent 3c1e3d7 commit cdd1192
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class ResourceJavaFileObject extends SimpleJavaFileObject {
@Override public Kind
getKind() { return kind; }

// SUPPRESS CHECKSTYLE LineLength:9
@Override public OutputStream openOutputStream() { throw new UnsupportedOperationException(); }
@Override public Reader openReader(boolean ignoreEncodingErrors) { throw new UnsupportedOperationException(); }
@Override public CharSequence getCharContent(boolean ignoreEncodingErrors) { throw new UnsupportedOperationException(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class ExternalClass extends BaseOfExternalClass implements InterfaceOfExternalClass {
public final OtherExternalClass x = new OtherExternalClass();

public static int m1() { return OtherExternalClass.m1(); } // SUPPRESS CHECKSTYLE LineLength:2
public static int m1() { return OtherExternalClass.m1(); }
@SuppressWarnings("static-method") public OtherExternalClass m2() { return null; }
public void m2(OtherExternalClass fc) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class CompilerTest {
? new File(CompilerTest.COMMONS_COMPILER_JDK_SRC + "/org/codehaus/commons/compiler/jdk/Compiler.java")
: new File(CompilerTest.JANINO_SRC + "/org/codehaus/janino/Compiler.java")
),
new File(CompilerTest.COMMONS_COMPILER_SRC + "/org/codehaus/commons/compiler/samples/ExpressionDemo.java"), // SUPPRESS CHECKSTYLE LineLength:2
new File(CompilerTest.COMMONS_COMPILER_SRC + "/org/codehaus/commons/compiler/samples/ExpressionDemo.java"),
new File(CompilerTest.COMMONS_COMPILER_SRC + "/org/codehaus/commons/compiler/util/resource/MapResourceCreator.java"),
new File(CompilerTest.COMMONS_COMPILER_SRC + "/org/codehaus/commons/compiler/util/resource/MapResourceFinder.java"),
};
Expand Down Expand Up @@ -640,7 +640,7 @@ class CompilerTest {

// Now compile two units with different package declarations.
compiler.compile(new Resource[] {
new StringResource("pkg1/A.java", "package pkg1; public class A { public static int meth() { return pkg2.B.meth(); } }"), // SUPPRESS CHECKSTYLE LineLength:4
new StringResource("pkg1/A.java", "package pkg1; public class A { public static int meth() { return pkg2.B.meth(); } }"),
new StringResource("pkg2/B.java", "package pkg2; public class B { public static int meth() { return 77; } }"),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class JlsTest extends CommonsCompilerTestSuite {
@Test public void
test_8_1_1__Class_Modifiers() throws Exception {

// Modifiers for package member class: SUPPRESS CHECKSTYLE LineLength:18
// Modifiers for package member class:
this.assertCompilationUnitCookable("@SuppressWarnings(\"foo\") class Foo {}");
this.assertCompilationUnitCookable("abstract class Foo {}");
this.assertCompilationUnitCookable("final class Foo {}");
Expand Down Expand Up @@ -876,7 +876,7 @@ class JlsTest extends CommonsCompilerTestSuite {
@Test public void
test_9_4__Method_Declarations__5() throws Exception {

// Modifiers for interface method: SUPPRESS CHECKSTYLE LineLength:18
// Modifiers for interface method:
this.assertCompilationUnitCookable("interface Foo { @SuppressWarnings(\"foo\") void meth(); }");
this.assertCompilationUnitCookable("interface Foo { abstract void meth(); }");
this.assertCompilationUnitCookable("interface Foo { public void meth(); }");
Expand Down Expand Up @@ -1149,7 +1149,6 @@ class JlsTest extends CommonsCompilerTestSuite {
+ " );\n"
+ " if (anno == null) throw new AssertionError(1);\n"
+ "\n"
// SUPPRESS CHECKSTYLE LineLength:13
+ " if (!anno.booleanValue()) throw new AssertionError(2);\n"
+ " if (anno.byteValue() != 127) throw new AssertionError(3);\n"
+ " if (anno.shortValue() != 32767) throw new AssertionError(4);\n"
Expand Down Expand Up @@ -1264,7 +1263,6 @@ class JlsTest extends CommonsCompilerTestSuite {
@Test public void
test_14_10__The_assert_statement() throws Exception {

// SUPPRESS CHECKSTYLE LineLength:5
this.assertScriptExecutable("assert true;");
this.assertScriptReturnsTrue("try { assert false; } catch (AssertionError ae) { return true; } return false;");
this.assertScriptReturnsTrue("try { assert false : \"x\"; } catch (AssertionError ae) { return \"x\".equals(ae.getMessage()); } return false;");
Expand Down Expand Up @@ -2949,7 +2947,7 @@ class JlsTest extends CommonsCompilerTestSuite {

// List 1, bullet 5
this.assertExpressionEvaluatesTrue("(true ? new Object() : \"\") != null");
this.assertExpressionEvaluatesTrue("(true ? new Object() : 7).getClass().getName().equals(\"java.lang.Object\")"); // SUPPRESS CHECKSTYLE LineLength:11
this.assertExpressionEvaluatesTrue("(true ? new Object() : 7).getClass().getName().equals(\"java.lang.Object\")");
this.assertExpressionEvaluatesTrue("(true ? new Object() : Integer.valueOf(7)).getClass().getName().equals(\"java.lang.Object\")");
this.assertExpressionEvaluatesTrue("(true ? Integer.valueOf(9) : Integer.valueOf(7)).getClass().getName().equals(\"java.lang.Integer\")");
this.assertExpressionEvaluatesTrue("(true ? Integer.valueOf(9) : Long.valueOf(7)) == 9L");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ class ReportedBugsTest extends CommonsCompilerTestSuite {

@Test public void
testBug169() throws Exception {
// SUPPRESS CHECKSTYLE LineLength:94
this.assertCompilationUnitCookable(
""
+ "import java.util.*;\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private CompilerFactoryFactory() {}
* @param compilerFactoryClassName Name of a class that implements {@link ICompilerFactory}
* @throws Exception Many things can go wrong while finding and initializing the default compiler
* factory
* @deprecated Use {@link #getCompilerFactory(String, ClassLoader)} instead
*/
@Deprecated public static ICompilerFactory
getCompilerFactory(String compilerFactoryClassName) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface ICompiler {
* @see #setClassFileFinder(ResourceFinder)
*/
ResourceFinder FIND_NEXT_TO_SOURCE_FILE = new ListableResourceFinder() {
@Override @Nullable public Resource findResource(String resourceName) { throw new UnsupportedOperationException("FIND_NEXT_TO_SOUJRCE_FILE"); } // SUPPRESS CHECKSTYLE LineLength:2
@Override @Nullable public Resource findResource(String resourceName) { throw new UnsupportedOperationException("FIND_NEXT_TO_SOUJRCE_FILE"); }
@Override @Nullable public Iterable<Resource> list(String resourceNamePrefix, boolean recurse) { return Collections.emptyList(); }
@Override public String toString() { return "FIND_NEXT_TO_SOUJRCE_FILE"; }
};
Expand All @@ -65,7 +65,7 @@ interface ICompiler {
* created in the directory of the .java resource from which they are generated.
*/
ResourceCreator CREATE_NEXT_TO_SOURCE_FILE = new ResourceCreator() {
@Override public boolean deleteResource(String resourceName) { throw new UnsupportedOperationException("CREATE_NEXT_TO_SOURCE_FILE"); } // SUPPRESS CHECKSTYLE LineLength:2
@Override public boolean deleteResource(String resourceName) { throw new UnsupportedOperationException("CREATE_NEXT_TO_SOURCE_FILE"); }
@Override public OutputStream createResource(String resourceName) { throw new UnsupportedOperationException("CREATE_NEXT_TO_SOURCE_FILE"); }
@Override public String toString() { return "CREATE_NEXT_TO_SOURCE_FILE"; }
};
Expand Down
2 changes: 2 additions & 0 deletions janino-parent/checkstyle-configuration/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@
</module>
</module>
<module name="LineLength">
<property name="severity" value="ignore"/>
<property name="max" value="120"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="JavadocPackage"/>
<module name="RegexpHeader">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ class ClassFileIClass extends IClass {

final ClassFile cf = ClassFileIClass.this.classFile;

// SUPPRESS CHECKSTYLE LineLength:13
@Override public Object visitBooleanElementValue(BooleanElementValue subject) { return this.getConstantValue(subject.constantValueIndex); }
@Override public Object visitByteElementValue(ByteElementValue subject) { return this.getConstantValue(subject.constantValueIndex); }
@Override public Object visitCharElementValue(CharElementValue subject) { return this.getConstantValue(subject.constantValueIndex); }
Expand Down Expand Up @@ -639,7 +638,7 @@ class ClassFileIClass extends IClass {
} else {

result = new IClass.IMethod() {
@Override public IAnnotation[] getAnnotations() { return iAnnotations; } // SUPPRESS CHECKSTYLE LineLength:9
@Override public IAnnotation[] getAnnotations() { return iAnnotations; }
@Override public Access getAccess() { return access; }
@Override public boolean isStatic() { return Mod.isStatic(methodInfo.getAccessFlags()); }
@Override public boolean isAbstract() { return Mod.isAbstract(methodInfo.getAccessFlags()); }
Expand Down
2 changes: 1 addition & 1 deletion janino/src/main/java/org/codehaus/janino/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class Compiler extends AbstractCompiler {

for (final ModuleReference mr : mrs) {
final URI moduleContentLocation = (URI) mr.location().get();
final URL classFileUrl = new URL(moduleContentLocation + "/" + resourceName); // SUPPRESS CHECKSTYLE LineLength
final URL classFileUrl = new URL(moduleContentLocation + "/" + resourceName);
final URLConnection uc = classFileUrl.openConnection();
try {
uc.connect();
Expand Down
2 changes: 0 additions & 2 deletions janino/src/main/java/org/codehaus/janino/IClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class IClassLoader {
this.TYPE_java_io_Serializable = this.requireType(Descriptor.JAVA_IO_SERIALIZABLE);
this.TYPE_java_util_Iterator = this.requireType(Descriptor.JAVA_UTIL_ITERATOR);

// SUPPRESS CHECKSTYLE LineLength:24
this.METH_java_lang_Enum__ordinal = IClassLoader.requireMethod(this.TYPE_java_lang_Enum, "ordinal");
this.METH_java_lang_Iterable__iterator = IClassLoader.requireMethod(this.TYPE_java_lang_Iterable, "iterator");
this.METH_java_lang_String__concat__java_lang_String = IClassLoader.requireMethod(this.TYPE_java_lang_String, "concat", this.TYPE_java_lang_String);
Expand All @@ -184,7 +183,6 @@ class IClassLoader {
this.METH_java_util_Iterator__hasNext = IClassLoader.requireMethod(this.TYPE_java_util_Iterator, "hasNext");
this.METH_java_util_Iterator__next = IClassLoader.requireMethod(this.TYPE_java_util_Iterator, "next");

// SUPPRESS CHECKSTYLE LineLength:1
this.CTOR_java_lang_StringBuilder__java_lang_String = IClassLoader.requireConstructor(this.TYPE_java_lang_StringBuilder, this.TYPE_java_lang_String);

} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion janino/src/main/java/org/codehaus/janino/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3772,7 +3772,7 @@ enum InterfaceDeclarationContext {

// Token-level methods.

// Shorthand for the various "TokenStream" methods. SUPPRESS CHECKSTYLE LineLength|JavadocMethod:16
// Shorthand for the various "TokenStream" methods.
public Token peek() throws CompileException, IOException { return this.tokenStream.peek(); }
public Token read() throws CompileException, IOException { return this.tokenStream.read(); }
public boolean peek(String suspected) throws CompileException, IOException { return this.tokenStream.peek(suspected); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class Script {
this.makeStatements(i, parsers[i], statements, localMethods);

statementss[i] = (BlockStatement[]) statements.toArray(new Java.BlockStatement[statements.size()]);
localMethodss[i] = (MethodDeclarator[]) localMethods.toArray(new Java.MethodDeclarator[localMethods.size()]); // SUPPRESS CHECKSTYLE LineLength
localMethodss[i] = (MethodDeclarator[]) localMethods.toArray(new Java.MethodDeclarator[localMethods.size()]);
}

this.cook(
Expand Down
Loading

0 comments on commit cdd1192

Please sign in to comment.