Fix or ignore some Sonar warnings
diff --git a/src/main/java/org/apache/sling/cta/impl/Agent.java b/src/main/java/org/apache/sling/cta/impl/Agent.java
index 3c5776b..d4d5ff2 100644
--- a/src/main/java/org/apache/sling/cta/impl/Agent.java
+++ b/src/main/java/org/apache/sling/cta/impl/Agent.java
@@ -28,7 +28,7 @@
import javax.management.NotCompliantMBeanException;
public class Agent {
-
+
public static void premain(String args, Instrumentation inst) {
String[] parsedArgs = args != null ? args.split(",") : new String[0];
@@ -68,5 +68,10 @@
}
Log.get().log("All transformers installed");
- }
+ }
+
+ // prevent instantiation
+ private Agent() {
+
+ }
}
diff --git a/src/main/java/org/apache/sling/cta/impl/Log.java b/src/main/java/org/apache/sling/cta/impl/Log.java
index e0e3213..0b7f4e3 100644
--- a/src/main/java/org/apache/sling/cta/impl/Log.java
+++ b/src/main/java/org/apache/sling/cta/impl/Log.java
@@ -32,7 +32,7 @@
*/
abstract class Log {
- private static Log INSTANCE;
+ private static Log INSTANCE; // NOSONAR - name is OK for static fields
/**
* Configures the global logger instance
@@ -87,13 +87,14 @@
@Override
public void log(String msg, Object... args) {
- System.out.format(LOG_ENTRY_PREFIX + msg + " %n", args);
+ System.out.format(LOG_ENTRY_PREFIX + msg + " %n", args); // NOSONAR - this is a logger, OK to use System.out
}
@Override
public void fatal(String msg, Throwable t) {
- t.printStackTrace(); // ensure _something_ is printed
- throw new RuntimeException(LOG_ENTRY_PREFIX + msg, t);
+ // ensure _something_ is printed, throwable might not be printed
+ t.printStackTrace(); // NOSONAR - OK to use printStackTrace, we are a logger
+ throw new RuntimeException(LOG_ENTRY_PREFIX + msg, t); // NOSONAR - we don't want custom exceptions
}
}
diff --git a/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java b/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
index d30745a..d3118f0 100644
--- a/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
+++ b/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
@@ -64,7 +64,7 @@
return classfileBuffer;
} catch (Exception e) {
Log.get().fatal("Transformation failed", e);
- return null;
+ return null; // NOSONAR: null return is OK in case no transform is performed
}
}
@@ -75,6 +75,6 @@
* @return the new class definition
* @throws Exception in case of any problems while transforming
*/
- protected abstract byte[] doTransformClass(CtClass cc) throws Exception;
+ protected abstract byte[] doTransformClass(CtClass cc) throws Exception; // NOSONAR - throwing Exception is OK, we don't want custom exceptions
}
\ No newline at end of file