-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F#2051006 Controller Service - Jenkins plugin integration #628
base: latest
Are you sure you want to change the base?
Conversation
src/main/java/com/microfocus/application/automation/tools/run/RunFromService.java
Show resolved
Hide resolved
src/main/java/com/microfocus/application/automation/tools/run/RunFromService.java
Show resolved
Hide resolved
URL cmdExeCfgUrl = Jenkins.get().pluginManager.uberClassLoader.getResource(HP_TOOLS_LAUNCHER_EXE_CFG); | ||
if (cmdExeCfgUrl == null) { | ||
listener.fatalError(HP_TOOLS_LAUNCHER_EXE_CFG + " not found in resources"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
URL cmdExe2Url = Jenkins.get().pluginManager.uberClassLoader.getResource(LRANALYSIS_LAUNCHER_EXE); | ||
if (cmdExe2Url == null) { | ||
listener.fatalError(LRANALYSIS_LAUNCHER_EXE + "not found in resources"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
LogMessage("Test completed in", elapsedTime); | ||
Dispose(client); | ||
Cleanup(processesToKill); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
} catch(IllegalArgumentException | EncryptionUtils.EncryptionException e) { | ||
build.setResult(Result.FAILURE); | ||
listener.fatalError(String.format("Build parameters check failed: %s.", e.getMessage())); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
URL cmdExeUrl = Jenkins.get().pluginManager.uberClassLoader.getResource(HP_TOOLS_LAUNCHER_EXE); | ||
if (cmdExeUrl == null) { | ||
listener.fatalError(HP_TOOLS_LAUNCHER_EXE + " not found in resources"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
mergedProperties.put("resultsFilename", ResultFilename); | ||
|
||
// parallel runner is enabled | ||
if (isParallelRunnerEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
} | ||
} | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
mergedProperties.put("printTestParams", isPrintTestParams ? "1" : "0"); | ||
|
||
UftRunAsUser uftRunAsUser; | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
if (UftToolUtils.isMtbxContent(expandedFsTests)) { | ||
testsArr = new String[]{expandedFsTests}; | ||
} else { | ||
testsArr = expandedFsTests.replaceAll("\r", "").split("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this call to "replaceAll()" by a call to the "replace()" method.
} | ||
|
||
@Override | ||
public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace, @Nonnull Launcher launcher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor this method to reduce its Cognitive Complexity from 44 to the 15 allowed.
EnvVars env = null; | ||
try { | ||
env = build.getEnvironment(listener); | ||
} catch (IOException | InterruptedException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.
|
||
// clean actual tests' report folders | ||
index = 1; | ||
while (mergedProperties.getProperty("Test" + index) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
|
||
// clean cleanuptests' report folders | ||
int index = 1; | ||
while (mergedProperties.getProperty("CleanupTest" + index) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
} | ||
|
||
@Override | ||
public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace, @Nonnull Launcher launcher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor this method to reduce its Cognitive Complexity from 39 to the 15 allowed.
// * | ||
// * @param fsTests the fs tests | ||
// */ | ||
// public RunFromService(String fsTests) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of commented-out lines of code should be removed.
Util.displayIOException(ioe, listener); | ||
build.setResult(Result.FAILURE); | ||
listener.error("Failed running HpToolsLauncher " + ioe.getMessage()); | ||
} catch (InterruptedException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
return createProperties(envVars, currNode); | ||
} | ||
|
||
private Properties createProperties(EnvVars envVars, Node currNode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this unused method parameter "currNode".
return UftToolUtils.getNodesList(); | ||
} | ||
|
||
// public List<String> getEncodings() { return RunFromServiceModel.encodings; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of commented-out lines of code should be removed.
if (StringUtils.isNotBlank(fsReportPath)) { | ||
props.put("fsReportPath", fsReportPath); | ||
} | ||
if (!StringUtils.isEmpty(this.fsTests)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
* @param value the value | ||
* @return the form validation | ||
*/ | ||
public FormValidation doCheckFsTimeout(@QueryParameter String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
} catch (IOException e1) { | ||
Util.displayIOException(e1, listener); | ||
build.setResult(Result.FAILURE); | ||
} catch (InterruptedException e1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.
Util.displayIOException(ioe, listener); | ||
build.setResult(Result.FAILURE); | ||
listener.error("Failed running HpToolsLauncher " + ioe.getMessage()); | ||
} catch (InterruptedException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.
CmdLineExe.copyFrom(cmdExeUrl); | ||
CmdLineExeCfg.copyFrom(cmdExeCfgUrl); | ||
CmdLineExe2.copyFrom(cmdExe2Url); | ||
} catch (IOException | InterruptedException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.
// * | ||
// * @param runFromServiceModel the run from file model | ||
// */ | ||
// public RunFromService(RunFromServiceModel runFromServiceModel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of commented-out lines of code should be removed.
|
||
// cleanup report folders before running the build | ||
String selectedNode = env.get("NODE_NAME"); | ||
if (selectedNode == null) {//if slave is given in the pipeline and not as part of build step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
return; | ||
} | ||
int idx = 0; | ||
for (Iterator<String> iterator = env.keySet().iterator(); iterator.hasNext(); ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
Code Climate has analyzed commit dc3dd6e and detected 30 issues on this pull request. Here's the issue category breakdown:
Note: there are 2 critical issues. View more on Code Climate. |
This is the first attempt at productizing the new Controller Service app.
We want to provide the additional functionality in our Jenkins plugin to run a test using the Controller Service, using an LRS file