SpotBugs Report

Project Information

Project: code-grader (spotbugsMain)

SpotBugs version: 4.7.0

Code analyzed:



Metrics

3748 lines of code analyzed, in 55 classes, in 3 packages.

Metric Total Density*
High Priority Warnings 7 1.87
Medium Priority Warnings 21 5.60
Total Warnings 28 7.47

(* Defects per Thousand lines of non-commenting source statements)



Contents

Summary

Warning Type Number
Bad practice Warnings 2
Experimental Warnings 1
Internationalization Warnings 6
Malicious code vulnerability Warnings 14
Performance Warnings 1
Dodgy code Warnings 4
Total 28

Warnings

Click on a warning row to see full context information.

Bad practice Warnings

Code Warning
RV Exceptional return value of java.io.File.mkdirs() ignored in edu.odu.cs.zeil.codegrader.Stage.setupSubmitterStage()
RV Exceptional return value of java.io.File.delete() ignored in edu.odu.cs.zeil.codegrader.TestCase.executeExternalTestCommand(Submission, Stage, String)

Experimental Warnings

Code Warning
LG Changes to logger could be lost in edu.odu.cs.zeil.codegrader.Logging.setup()

Internationalization Warnings

Code Warning
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.FileUtils.writeTextFile(Path, String): new java.io.FileWriter(File)
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.TestCase.executeExternalTestCommand(Submission, Stage, String): new java.io.FileWriter(File)
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.TestSuite.recordInGradeLog(Path, Submission, int): new java.io.FileWriter(File)
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.TestSuite.recordInGradeLog(Path, Submission, int): new java.io.FileWriter(File, boolean)
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.oracle.JUnit5Oracle.parseGradleReport(): new java.io.FileReader(File)
Dm Found reliance on default encoding in edu.odu.cs.zeil.codegrader.oracle.JUnit5Oracle.parseMavenReport(): new java.io.FileReader(File)

Malicious code vulnerability Warnings

Code Warning
EI edu.odu.cs.zeil.codegrader.TestCase.getProperties() may expose internal representation by returning TestCase.properties
EI edu.odu.cs.zeil.codegrader.TestCaseProperties.getAssignment() may expose internal representation by returning TestCaseProperties.assignment
EI edu.odu.cs.zeil.codegrader.oracle.Oracle.getStage() may expose internal representation by returning Oracle.stage
EI2 new edu.odu.cs.zeil.codegrader.DefaultBuildCase(TestSuiteProperties, Assignment) may expose internal representation by storing an externally mutable object into DefaultBuildCase.assignment
EI2 new edu.odu.cs.zeil.codegrader.DefaultBuildCase(TestSuiteProperties, Assignment) may expose internal representation by storing an externally mutable object into DefaultBuildCase.suite
EI2 new edu.odu.cs.zeil.codegrader.Stage(Assignment, Submission, TestSuiteProperties) may expose internal representation by storing an externally mutable object into Stage.assignment
EI2 new edu.odu.cs.zeil.codegrader.Stage(Assignment, Submission, TestSuiteProperties) may expose internal representation by storing an externally mutable object into Stage.properties
EI2 new edu.odu.cs.zeil.codegrader.Stage(Assignment, TestSuiteProperties) may expose internal representation by storing an externally mutable object into Stage.assignment
EI2 new edu.odu.cs.zeil.codegrader.Stage(Assignment, TestSuiteProperties) may expose internal representation by storing an externally mutable object into Stage.properties
EI2 new edu.odu.cs.zeil.codegrader.Submission(Assignment, String, Path) may expose internal representation by storing an externally mutable object into Submission.assignment
EI2 new edu.odu.cs.zeil.codegrader.SubmissionSet(Assignment) may expose internal representation by storing an externally mutable object into SubmissionSet.assignment
EI2 new edu.odu.cs.zeil.codegrader.TestCase(TestCaseProperties) may expose internal representation by storing an externally mutable object into TestCase.properties
EI2 new edu.odu.cs.zeil.codegrader.TestCaseProperties(Assignment, String) may expose internal representation by storing an externally mutable object into TestCaseProperties.assignment
EI2 new edu.odu.cs.zeil.codegrader.TestSuite(Assignment) may expose internal representation by storing an externally mutable object into TestSuite.assignment

Performance Warnings

Code Warning
SIC Should edu.odu.cs.zeil.codegrader.TestSuite$Detail be a _static_ inner class?

Dodgy code Warnings

Code Warning
DLS Dead store to paramString in edu.odu.cs.zeil.codegrader.TestCase.executeInternalTestCommand(Submission, Stage, String)
DLS Dead store to caseProperties in new edu.odu.cs.zeil.codegrader.TestCaseProperties(Assignment, String)
NP Possible null pointer dereference in edu.odu.cs.zeil.codegrader.oracle.JUnit5Oracle.parseMavenReport() due to return value of called method
UrF Unread public/protected field: edu.odu.cs.zeil.codegrader.BuildProperties.timeLimit

Details

DLS_DEAD_LOCAL_STORE: Dead store to local variable

This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.

DM_DEFAULT_ENCODING: Reliance on default encoding

Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.

EI_EXPOSE_REP: May expose internal representation by returning reference to mutable object

Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.

EI_EXPOSE_REP2: May expose internal representation by incorporating reference to mutable object

This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.

LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE: Potential lost logger changes due to weak reference in OpenJDK

OpenJDK introduces a potential incompatibility. In particular, the java.util.logging.Logger behavior has changed. Instead of using strong references, it now uses weak references internally. That's a reasonable change, but unfortunately some code relies on the old behavior - when changing logger configuration, it simply drops the logger reference. That means that the garbage collector is free to reclaim that memory, which means that the logger configuration is lost. For example, consider:

public static void initLogging() throws Exception {
    Logger logger = Logger.getLogger("edu.umd.cs");
    logger.addHandler(new FileHandler()); // call to change logger configuration
    logger.setUseParentHandlers(false); // another call to change logger configuration
}

The logger reference is lost at the end of the method (it doesn't escape the method), so if you have a garbage collection cycle just after the call to initLogging, the logger configuration is lost (because Logger only keeps weak references).

public static void main(String[] args) throws Exception {
    initLogging(); // adds a file handler to the logger
    System.gc(); // logger configuration lost
    Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected
}

Ulf Ochsenfahrt and Eric Fellheimer

NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Possible null pointer dereference due to return value of called method

The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: Method ignores exceptional return value

This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.

SIC_INNER_SHOULD_BE_STATIC: Should be a static inner class

This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be made static.

URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD: Unread public/protected field

This field is never read.  The field is public or protected, so perhaps it is intended to be used with classes not seen as part of the analysis. If not, consider removing it from the class.