CloudSlang/cs-actions

View on GitHub
cs-powershell/src/main/java/io/cloudslang/content/services/WSManRemoteShellService.java

Summary

Maintainability
C
1 day
Test Coverage

Method createReceiveRequestBody has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private String createReceiveRequestBody(String doc, String url, String shellId, String commandId, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {

    Method createExecuteCommandRequestBody has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        private String createExecuteCommandRequestBody(String doc, String url, String shellId, String command, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {

      Method createDeleteShellRequestBody has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private String createDeleteShellRequestBody(String doc, String url, String shellId, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {

        Method receiveCommandResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private Map<String, String> receiveCommandResult(HttpClientService csHttpClient, HttpClientInputs httpClientInputs,
                                                             String shellId, String commandId, WSManRequestInputs wsManRequestInputs) throws Exception {
                String documentStr = ResourceLoader.loadAsString(RECEIVE_REQUEST_XML);
                documentStr = createReceiveRequestBody(documentStr, httpClientInputs.getUrl(), shellId, commandId, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout()));
                Map<String, String> receiveResult;

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method receiveCommandResult has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private Map<String, String> receiveCommandResult(HttpClientService csHttpClient, HttpClientInputs httpClientInputs,
                                                             String shellId, String commandId, WSManRequestInputs wsManRequestInputs) throws Exception {

          Method createCreateShellRequestBody has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private String createCreateShellRequestBody(String doc, String url, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {

            Method replaceCommonPlaceholders has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private String replaceCommonPlaceholders(String doc, String url, String maxEnvelopeSize, String winrmLocale, String operationTimeout) {

              Method executeCommand has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId,
                                                WSManRequestInputs wsManRequestInputs, String command) throws Exception {

                Method getResourceId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException {
                        if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) {
                            String shellId = XMLUtils.parseXml(response, resourceIdXpath);
                            if (StringUtils.isNotBlank(shellId)) {
                                return shellId;

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    private String createReceiveRequestBody(String doc, String url, String shellId, String commandId, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {
                        doc = replaceCommonPlaceholders(doc, url, maxEnvelopeSize, winrmLocale, operationTimeout);
                        doc = replacePlaceholder(doc, SHELL_ID_PLACEHOLDER_NAME, shellId);
                        doc = replacePlaceholder(doc, MESSAGE_ID_PLACEHOLDER_NAME, UUID_LABEL + UUID.randomUUID().toString());
                        return replacePlaceholder(doc, COMMAND_ID_PLACEHOLDER_NAME, commandId);
                cs-powershell/src/main/java/io/cloudslang/content/services/WSManRemoteShellService.java on lines 403..408

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 74.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    private String createExecuteCommandRequestBody(String doc, String url, String shellId, String command, String maxEnvelopeSize, String winrmLocale, String operationTimeout) throws RuntimeException {
                        doc = replaceCommonPlaceholders(doc, url, maxEnvelopeSize, winrmLocale, operationTimeout);
                        doc = replacePlaceholder(doc, SHELL_ID_PLACEHOLDER_NAME, shellId);
                        doc = replacePlaceholder(doc, MESSAGE_ID_PLACEHOLDER_NAME, UUID_LABEL + UUID.randomUUID().toString());
                        return replacePlaceholder(doc, COMMAND_PLACEHOLDER_NAME, command);
                cs-powershell/src/main/java/io/cloudslang/content/services/WSManRemoteShellService.java on lines 410..415

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 74.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status