Skip to content

Commit

Permalink
CodacyFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vodorok committed Sep 23, 2019
1 parent c0654c1 commit 7b406a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import org.codechecker.eclipse.plugin.runtime.ShellExecutorHelper;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import com.google.common.base.Optional;

/**
* Internal representation of a CodeChecker package.
*/
public class CodeChecker implements ICodeChecker {
private static final String OPTION_SEPARATOR = " ";

private static final String LOCATION_KEY = "location";
private static final String RESULTS_KEY = "results";
Expand Down Expand Up @@ -91,30 +93,31 @@ public String analyze(Path logFile, boolean logToConsole, IProgressMonitor monit
}

@Override
public String getAnalyzeString(CcConfigurationBase config, Path logFile) {
public String getAnalyzeString(CcConfigurationBase config, @Nullable Path logFile) {
if (logFile != null) {
subMap.put(RESULTS_KEY, logFile.getParent().toAbsolutePath().resolve(Paths.get(RESULTS_FOLDER)).toFile());
subMap.put(LOGFILE_KEY, logFile.toAbsolutePath().toFile());
}

String[] temp = getSubstituteAnalyzeString(config).split(" ");
String[] temp = getSubstituteAnalyzeString(config).split(OPTION_SEPARATOR);
StringBuilder cmd = new StringBuilder();
for (String s : temp) {
String tempString = s;
if (s.startsWith("${")) {
StringBuilder sb = new StringBuilder(s);
StringBuilder sb = new StringBuilder(tempString);
sb.delete(0, 2).deleteCharAt(sb.length() - 1);
if (subMap.containsKey(sb.toString()))
s = subMap.get(sb.toString()).toString();
tempString = subMap.get(sb.toString()).toString();
}
cmd.append(s);
cmd.append(' ');
cmd.append(tempString);
cmd.append(OPTION_SEPARATOR);
}
return cmd.toString();
}

private String getSubstituteAnalyzeString(CcConfigurationBase config) {
return LOCATION_SUB + " analyze" + " -j "
+ config.get(ConfigTypes.ANAL_THREADS) + " -n javarunner" + " -o " + RESULTS_SUB + " " + LOGFILE_SUB
+ " " + config.get(ConfigTypes.ANAL_OPTIONS);
+ config.get(ConfigTypes.ANAL_THREADS) + " -n javarunner" + " -o " + RESULTS_SUB + OPTION_SEPARATOR
+ LOGFILE_SUB + OPTION_SEPARATOR + config.get(ConfigTypes.ANAL_OPTIONS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.codechecker.eclipse.plugin.config.CcConfigurationBase;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

/**
* Interface representing a CodeChecker package.
Expand Down Expand Up @@ -40,10 +41,15 @@ public interface ICodeChecker {

/**
* Returns the analyze command to be run, without extra parameters.
*
*
* @param logFile
* A Path to the build log in the following format:
* http://clang.llvm.org/docs/JSONCompilationDatabase.html .
* @param config
* The configuration being used.
* @return The analyze command as String.
*/
public String getAnalyzeString(CcConfigurationBase config, Path logFile);
public String getAnalyzeString(CcConfigurationBase config, @Nullable Path logFile);

/**
* Executes CodeChecker check command on the build log received in the logFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class CommonGui {
private static final int FORM_COLUMNS = 3;
private static final int FORM_ONE_ROW = 1;

private static final int AN_CMD_DISP_HGT = 300;
private static final int TRI_LINE_TEXT_HGT = 52;

private boolean globalGui;// whether this class is for global or project
// specific preferences
private boolean useGlobalSettings;// if this is project specific page,
Expand Down Expand Up @@ -176,7 +179,7 @@ public Control createContents(final Composite parent) {

toolkit.createLabel(comp, "Extra analysis options");
analysisOptions = toolkit.createText(comp, "", SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(false, true).hint(TEXTWIDTH, 52).applyTo(analysisOptions);
GridDataFactory.fillDefaults().grab(false, true).hint(TEXTWIDTH, TRI_LINE_TEXT_HGT).applyTo(analysisOptions);
analysisOptions.addModifyListener(new ModifyListener() {

@Override
Expand All @@ -199,7 +202,7 @@ public void modifyText(ModifyEvent e) {
toolkit.createLabel(comp, "");
toolkit.createLabel(comp, "Final analysis command");
analysisCmdDisplay = toolkit.createText(comp, "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(false, true).hint(TEXTWIDTH, 300).applyTo(analysisCmdDisplay);
GridDataFactory.fillDefaults().grab(false, true).hint(TEXTWIDTH, AN_CMD_DISP_HGT).applyTo(analysisCmdDisplay);
analysisCmdDisplay.setEditable(false);
analysisCmdDisplay.getVerticalBar().setEnabled(true);
toolkit.createLabel(comp, "");
Expand Down

0 comments on commit 7b406a0

Please sign in to comment.