Skip to content

Commit

Permalink
[eclipse-format] No longer supply version to spotless, use same confi…
Browse files Browse the repository at this point in the history
…guration (#2612)

far smaller subset of corrections making code easier to read.
  • Loading branch information
hazendaz committed Oct 9, 2023
1 parent 63618ab commit cfcf9f2
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spotless {
java {
removeUnusedImports()
trimTrailingWhitespace()
eclipse("4.13").configFile "${rootProject.projectDir}/gradle/eclipse-formatter.xml"
eclipse().configFile "${rootProject.projectDir}/gradle/eclipse-formatter.xml"
endWithNewline()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public static Set<JavaClassAndMethod> resolveMethodCallTargets(ReferenceType rec
if (false && subTypeSet.size() > 500) {
new RuntimeException(receiverClassName + " has " + subTypeSet.size() + " subclasses, " + result.size()
+ " of which implement " + methodName + methodSig + " " + invokeInstruction)
.printStackTrace(System.out);
.printStackTrace(System.out);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void sawOpcode(int seen) {
bugReporter.reportBug(new BugInstance(this,
"java/sql/PreparedStatement".equals(clsConstant) ? "SQL_BAD_PREPARED_STATEMENT_ACCESS"
: "SQL_BAD_RESULTSET_ACCESS", item.mustBeZero() ? HIGH_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(this).addSourceLine(this));
.addClassAndMethod(this).addSourceLine(this));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void sawOpcode(int seen) {
&& "setMaximumPoolSize".equals(getNameConstantOperand())) {
accumulator.accumulateBug(new BugInstance(DumbMethods.this,
"DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR", HIGH_PRIORITY)
.addClassAndMethod(DumbMethods.this), DumbMethods.this);
.addClassAndMethod(DumbMethods.this), DumbMethods.this);
}
}
}
Expand Down Expand Up @@ -756,7 +756,7 @@ public void sawOpcode(int seen) {
primitiveType.equals("Z") ? LOW_PRIORITY
: primitiveType.equals("B") ? NORMAL_PRIORITY
: HIGH_PRIORITY).addClassAndMethod(this).addCalledMethod(this).addMethod(shouldCall)
.describe(MethodAnnotation.SHOULD_CALL);
.describe(MethodAnnotation.SHOULD_CALL);
accumulator.accumulateBug(bug, this);
}
}
Expand Down Expand Up @@ -1264,7 +1264,7 @@ && getClassConstantOperand().startsWith("javax/swing/")

accumulator.accumulateBug(new BugInstance(this, "DMI_CALLING_NEXT_FROM_HASNEXT", item.isInitialParameter()
&& item.getRegisterNumber() == 0 ? NORMAL_PRIORITY : LOW_PRIORITY).addClassAndMethod(this)
.addCalledMethod(this), this);
.addCalledMethod(this), this);

}

Expand Down Expand Up @@ -1422,9 +1422,9 @@ && getClassConstantOperand().equals(primitiveObjCtorSeen)
&& dblString.toUpperCase().indexOf('E') == -1;
bugReporter.reportBug(new BugInstance(this, "DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE",
scary ? NORMAL_PRIORITY : LOW_PRIORITY).addClassAndMethod(this).addCalledMethod(this)
.addMethod("java.math.BigDecimal", "valueOf", "(D)Ljava/math/BigDecimal;", true)
.describe(MethodAnnotation.METHOD_ALTERNATIVE_TARGET).addString(dblString)
.addString(bigDecimalString).addSourceLine(this));
.addMethod("java.math.BigDecimal", "valueOf", "(D)Ljava/math/BigDecimal;", true)
.describe(MethodAnnotation.METHOD_ALTERNATIVE_TARGET).addString(dblString)
.addString(bigDecimalString).addSourceLine(this));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ && getClassConstantOperand().equals(streamType)) {
.reportBug(new BugInstance(this,
"java/util/zip/ZipOutputStream".equals(streamType) ? "AM_CREATES_EMPTY_ZIP_FILE_ENTRY"
: "AM_CREATES_EMPTY_JAR_FILE_ENTRY", NORMAL_PRIORITY).addClassAndMethod(this)
.addSourceLine(this));
.addSourceLine(this));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private void analyzeMethod(ClassContext classContext, Method method) throws Data
}
BugInstance bugInstance = new BugInstance(this, "DLS_DEAD_STORE_OF_CLASS_LITERAL",
Priorities.NORMAL_PRIORITY).addClassAndMethod(methodGen, sourceFileName).add(lvAnnotation)
.addType(initializationOf);
.addType(initializationOf);
accumulator.accumulateBug(bugInstance, sourceLineAnnotation);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void sawOpcode(int seen) {
bugAccumulator.accumulateBug(
new BugInstance(this, "FI_EXPLICIT_INVOCATION", "finalize".equals(getMethodName())
&& "()V".equals(getMethodSig()) ? HIGH_PRIORITY : NORMAL_PRIORITY).addClassAndMethod(this)
.addCalledMethod(this), this);
.addCalledMethod(this), this);

}
if (seen == Const.INVOKESPECIAL && "finalize".equals(getNameConstantOperand())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public void report() {
} else {
bugInstance = new BugInstance(this, guardedByThis ? "IS_FIELD_NOT_GUARDED" : "IS2_INCONSISTENT_SYNC",
Priorities.NORMAL_PRIORITY).addClass(xfield.getClassName()).addField(xfield).addInt(printFreq)
.describe(IntAnnotation.INT_SYNC_PERCENT);
.describe(IntAnnotation.INT_SYNC_PERCENT);
}

propertySet.decorateBugInstance(bugInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void analyzeMethod(ClassContext classContext, Method method) {
if (isSubtype) {
bugReporter.reportBug(new BugInstance(this, "JLM_JSR166_LOCK_MONITORENTER", isUtilConcurrentSig ? HIGH_PRIORITY
: NORMAL_PRIORITY).addClassAndMethod(classContext.getJavaClass(), method).addType(sig)
.addSourceForTopStackValue(classContext, method, location).addSourceLine(classContext, method, location));
.addSourceForTopStackValue(classContext, method, location).addSourceLine(classContext, method, location));
} else if (isUtilConcurrentSig) {

int priority = "Ljava/util/concurrent/CopyOnWriteArrayList;".equals(sig) ? HIGH_PRIORITY : NORMAL_PRIORITY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void sawOpcode(int seen) {
if (f.getName().equals(local.getName()) && (f.isStatic() || !getMethod().isStatic())) {
bugReporter.reportBug(new BugInstance(this, "SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD",
priority).addClassAndMethod(this).add(local).addField(f)
.describe(FieldAnnotation.DID_YOU_MEAN_ROLE).addSourceLine(this));
.describe(FieldAnnotation.DID_YOU_MEAN_ROLE).addSourceLine(this));
return;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void analyzeMethod(ClassContext classContext, Method method) throws CFGB

bugAccumulator.accumulateBug(new BugInstance(this, "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION",
isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
sourceLineAnnotation);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ private void analyzeMethod(ClassContext classContext, Method method) throws CFGB

bugReporter.reportBug(new BugInstance(this, "DMI_NONSERIALIZABLE_OBJECT_WRITTEN",
isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE)
.addSourceLine(sourceLineAnnotation));
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE)
.addSourceLine(sourceLineAnnotation));

} catch (ClassNotFoundException e) {
// ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private void examinePutfieldInstruction(Location location, PUTFIELD ins, Constan

BugInstance warning = new BugInstance(this, "NP_STORE_INTO_NONNULL_FIELD", tos.isDefinitelyNull() ? HIGH_PRIORITY
: NORMAL_PRIORITY).addClassAndMethod(classContext.getJavaClass(), method).addField(field)
.addOptionalAnnotation(variableAnnotation).addSourceLine(classContext, method, location);
.addOptionalAnnotation(variableAnnotation).addSourceLine(classContext, method, location);

bugReporter.reportBug(warning);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private boolean checkAndRecordCallFromConstructor(XMethod constructor, XMethod c
if (overridable != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", LOW_PRIORITY)
.addClass(this).addMethod(constructor).addString(overridable.getName()), sourceLine);
.addClass(this).addMethod(constructor).addString(overridable.getName()), sourceLine);
return false;
}
callerConstructors.put(callee, new CallerInfo(constructor, sourceLine));
Expand All @@ -240,7 +240,7 @@ private boolean checkAndRecordCallFromClone(XMethod clone, XMethod callee,
if (overridable != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CLONE", NORMAL_PRIORITY)
.addClass(this).addMethod(clone).addString(overridable.getName()), sourceLine);
.addClass(this).addMethod(clone).addString(overridable.getName()), sourceLine);
return false;
}
callerClones.put(callee, new CallerInfo(clone, sourceLine));
Expand All @@ -252,15 +252,15 @@ private boolean checkAndRecordCallToOverridable(XMethod caller, XMethod overrida
if (constructor != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", LOW_PRIORITY)
.addClassAndMethod(constructor.method).addString(overridable.getName()),
.addClassAndMethod(constructor.method).addString(overridable.getName()),
constructor.sourceLine);
}

CallerInfo clone = getIndirectCallerClone(caller);
if (clone != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CLONE", NORMAL_PRIORITY)
.addClassAndMethod(clone.method).addString(overridable.getName()), clone.sourceLine);
.addClassAndMethod(clone.method).addString(overridable.getName()), clone.sourceLine);
}

if (constructor != null || clone != null) {
Expand All @@ -281,15 +281,15 @@ private boolean checkAndRecordCallBetweenNonOverridableMethods(XMethod caller, X
if (constructor != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", LOW_PRIORITY)
.addClassAndMethod(constructor.method).addString(overridable.getName()),
.addClassAndMethod(constructor.method).addString(overridable.getName()),
constructor.sourceLine);

}

if (clone != null) {
bugAccumulator.accumulateBug(new BugInstance(this,
"MC_OVERRIDABLE_METHOD_CALL_IN_CLONE", NORMAL_PRIORITY)
.addClassAndMethod(clone.method).addString(overridable.getName()),
.addClassAndMethod(clone.method).addString(overridable.getName()),
clone.sourceLine);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,29 +334,29 @@ private boolean isTheSame(CallerInfo inside, CalleeInfo outside, OpcodeStack.Ite
private void reportBug(CallPair callPair) {
bugAccumulator.accumulateBug(new BugInstance(this, "USC_POTENTIAL_SECURITY_CHECK_BASED_ON_UNTRUSTED_SOURCE",
NORMAL_PRIORITY)
.addClassAndMethod(this)
.addSourceLine(this)
.addClass(callPair.outside.calledClass.getClassName())
.addCalledMethod(callPair.outside.calledClass.getClassName(),
callPair.outside.calledMethod.getName(), callPair.outside.calledMethod.getSignature(),
callPair.outside.calledMethod.isStatic())
.addSourceLine(callPair.outside.srcLine)
.addSourceLine(callPair.inside.srcLine), this);
.addClassAndMethod(this)
.addSourceLine(this)
.addClass(callPair.outside.calledClass.getClassName())
.addCalledMethod(callPair.outside.calledClass.getClassName(),
callPair.outside.calledMethod.getName(), callPair.outside.calledMethod.getSignature(),
callPair.outside.calledMethod.isStatic())
.addSourceLine(callPair.outside.srcLine)
.addSourceLine(callPair.inside.srcLine), this);
}

private void reportBug(JavaClass cls, XMethod method, SourceLineAnnotation srcLine,
CalleeInfo calleInfo, SourceLineAnnotation insideSrcLine) {
bugAccumulator.accumulateBug(new BugInstance(this, "USC_POTENTIAL_SECURITY_CHECK_BASED_ON_UNTRUSTED_SOURCE",
NORMAL_PRIORITY)
.addClass(cls)
.addMethod(method)
.addSourceLine(srcLine)
.addClass(calleInfo.calledClass.getClassName())
.addCalledMethod(calleInfo.calledClass.getClassName(),
calleInfo.calledMethod.getName(), calleInfo.calledMethod.getSignature(),
calleInfo.calledMethod.isStatic())
.addSourceLine(calleInfo.srcLine)
.addSourceLine(insideSrcLine), this);
.addClass(cls)
.addMethod(method)
.addSourceLine(srcLine)
.addClass(calleInfo.calledClass.getClassName())
.addCalledMethod(calleInfo.calledClass.getClassName(),
calleInfo.calledMethod.getName(), calleInfo.calledMethod.getSignature(),
calleInfo.calledMethod.isStatic())
.addSourceLine(calleInfo.srcLine)
.addSourceLine(insideSrcLine), this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void sawOpcode(int seen) {
bugReporter.reportBug(new BugInstance(this,
"PA_PUBLIC_PRIMITIVE_ATTRIBUTE",
NORMAL_PRIORITY)
.addClass(this).addField(field).addSourceLine(sla));
.addClass(this).addField(field).addSourceLine(sla));
writtenFields.add(field);
} else if (seen == Const.AASTORE) {
XField field = stack.getStackItem(2).getXField();
Expand All @@ -141,7 +141,7 @@ public void sawOpcode(int seen) {
bugReporter.reportBug(new BugInstance(this,
"PA_PUBLIC_ARRAY_ATTRIBUTE",
NORMAL_PRIORITY)
.addClass(this).addField(field).addSourceLine(sla));
.addClass(this).addField(field).addSourceLine(sla));
writtenFields.add(field);
} else if (seen == Const.INVOKEINTERFACE || seen == Const.INVOKEVIRTUAL) {
XMethod xmo = getXMethodOperand();
Expand Down Expand Up @@ -188,7 +188,7 @@ public void sawOpcode(int seen) {
bugReporter.reportBug(new BugInstance(this,
"PA_PUBLIC_MUTABLE_OBJECT_ATTRIBUTE",
NORMAL_PRIORITY)
.addClass(this).addField(field).addSourceLine(sla));
.addClass(this).addField(field).addSourceLine(sla));
writtenFields.add(field);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ && getPrevOpcode(1) == Const.IUSHR && !shiftOfNonnegativeValue
valueOfConstantArgumentToShift < 0 ? LOW_PRIORITY
: (valueOfConstantArgumentToShift == 32
&& "hashCode".equals(getMethodName()) ? NORMAL_PRIORITY : HIGH_PRIORITY))
.addClassAndMethod(this).addInt(valueOfConstantArgumentToShift).describe(
IntAnnotation.INT_SHIFT)
.addValueSource(stack.getStackItem(1), this), this);
.addClassAndMethod(this).addInt(valueOfConstantArgumentToShift).describe(
IntAnnotation.INT_SHIFT)
.addValueSource(stack.getStackItem(1), this), this);
}
}
if (leftHandSide instanceof Integer && ((Integer) leftHandSide) > 0) {
Expand Down
Loading

0 comments on commit cfcf9f2

Please sign in to comment.