Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package zingg.common.client;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import zingg.common.client.arguments.model.IArguments;
import zingg.common.client.arguments.model.IZArgs;

public class ArgumentsAssembler {

public final Log LOG = LogFactory.getLog(ArgumentsAssembler.class);

Check warning on line 10 in common/client/src/main/java/zingg/common/client/ArgumentsAssembler.java

View workflow job for this annotation

GitHub Actions / PMD Static Code Analysis

Logger should be defined private static final and have the correct class

A logger should normally be defined private static final and be associated with the correct class. `private final Log log;` is also allowed for rare cases where loggers need to be passed around, with the restriction that the logger needs to be passed into the constructor. ProperLogger (Priority: 3, Ruleset: Error Prone) https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#properlogger

public IZArgs assemble(IZArgs args, ClientOptions options) {
int jobId = Long.valueOf(System.currentTimeMillis()).intValue();;

Check warning on line 13 in common/client/src/main/java/zingg/common/client/ArgumentsAssembler.java

View workflow job for this annotation

GitHub Actions / PMD Static Code Analysis

Unnecessary semicolon

Reports unnecessary semicolons (so called "empty statements" and "empty declarations"). These can be removed without changing the program. The Java grammar allows them for historical reasons, but they should be avoided. This rule will not report empty statements that are syntactically required, for instance, because they are the body of a control statement. This rule replaces EmptyStatementNotInLoop. UnnecessarySemicolon (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#unnecessarysemicolon

if (options.get(ClientOptions.JOBID) != null) {
LOG.info("Using job id from command line");
jobId = Integer.parseInt(options.get(ClientOptions.JOBID).getValue());
Comment thread
sonalgoyal marked this conversation as resolved.
} else if (args.getJobId() != -1) {
jobId = args.getJobId();
}
args.setJobId(jobId);
if (options.get(ClientOptions.ZINGG_DIR) != null) {
args.setZinggDir(options.get(ClientOptions.ZINGG_DIR).getValue());
}
if (options.get(ClientOptions.MODEL_ID) != null) {
args.setModelId(options.get(ClientOptions.MODEL_ID).getValue());
}
if (options.get(ClientOptions.COLLECT_METRICS) != null) {
args.setCollectMetrics(Boolean.parseBoolean(options.get(ClientOptions.COLLECT_METRICS).getValue()));
}
if (options.get(ClientOptions.SHOW_CONCISE) != null && args instanceof IArguments) {
((IArguments) args).setShowConcise(Boolean.parseBoolean(options.get(ClientOptions.SHOW_CONCISE).getValue()));
}
if (options.get(ClientOptions.COLUMN) != null && args instanceof IArguments) {
((IArguments) args).setColumn(options.get(ClientOptions.COLUMN).getValue());
}
return args;
}
}
46 changes: 46 additions & 0 deletions common/client/src/main/java/zingg/common/client/BannerPrinter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package zingg.common.client;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class BannerPrinter {

private static final Log LOG = LogFactory.getLog(BannerPrinter.class);
Comment thread
sonalgoyal marked this conversation as resolved.

public void print(boolean collectMetrics) {
String productName = getProductName();
String version = getProductVersion();
LOG.info("");
LOG.info("**************************************************************************");
LOG.info("* *");
LOG.info("* "+productName+" *");

Check failure on line 16 in common/client/src/main/java/zingg/common/client/BannerPrinter.java

View workflow job for this annotation

GitHub Actions / PMD Static Code Analysis

Logger calls should be surrounded by log level guards.

Whenever using a log level, one should check if it is actually enabled, or otherwise skip the associate String creation and manipulation, as well as any method calls. An alternative to checking the log level are substituting parameters, formatters or lazy logging with lambdas. The available alternatives depend on the actual logging framework. GuardLogStatement (Priority: 2, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#guardlogstatement
LOG.info("* (C) 2021 Zingg Labs, Inc. *");
LOG.info("* *");
LOG.info("* https://www.zingg.ai/ *");
LOG.info("* *");
LOG.info("* using: Zingg v"+version+" *");

Check failure on line 21 in common/client/src/main/java/zingg/common/client/BannerPrinter.java

View workflow job for this annotation

GitHub Actions / PMD Static Code Analysis

Logger calls should be surrounded by log level guards.

Whenever using a log level, one should check if it is actually enabled, or otherwise skip the associate String creation and manipulation, as well as any method calls. An alternative to checking the log level are substituting parameters, formatters or lazy logging with lambdas. The available alternatives depend on the actual logging framework. GuardLogStatement (Priority: 2, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#guardlogstatement
LOG.info("* *");
if(collectMetrics) {
LOG.info("* ** Note about analytics collection by Zingg AI ** *");
LOG.info("* *");
LOG.info("* Please note that Zingg captures a few metrics about application's *");
LOG.info("* runtime parameters. However, no personal data or application data *");
LOG.info("* is captured. If you want to switch off this feature, please set the *");
LOG.info("* flag collectMetrics to false in config. For details, please refer to *");
LOG.info("* the Zingg docs (https://docs.zingg.ai/zingg/security). *");
LOG.info("* *");
LOG.info("**************************************************************************");
LOG.info("");
}
else {
LOG.info("* Zingg is not collecting any analytics data and will only log a blank *");
LOG.info("* event with name of the phase. *");
LOG.info("* *");
LOG.info("**************************************************************************");
LOG.info("");
}
}

protected String getProductName(){ return "Zingg AI"; }
protected String getProductVersion(){ return "0.6.0"; }
}
Loading
Loading