CloudSlang/cs-actions

View on GitHub
cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java

Summary

Maintainability
C
1 day
Test Coverage

XmlUtils has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

public class XmlUtils {
    private static final String OK_STATUS_CODE = "200";

    private XmlUtils() {
    }
Severity: Minor
Found in cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java - About 2 hrs to fix

    File XmlUtils.java has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright 2022-2024 Open Text
     * This program and the accompanying materials
     * are made available under the terms of the Apache License v2.0 which accompany this distribution.
     *
    Severity: Minor
    Found in cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java - About 2 hrs to fix

      Method getNamespaceContext has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static NamespaceContext getNamespaceContext(String xmlString, String xmlFilePath) throws Exception {
              InputStream inputXML = getStream(xmlString, xmlFilePath);
              XMLInputFactory inputFactory = XMLInputFactory.newInstance();
              XMLStreamReader reader = inputFactory.createXMLStreamReader(inputXML);
              Map<String, String> namespaces = new HashMap<>();
      Severity: Minor
      Found in cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java - About 1 hr to fix

      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 createXmlDocumentFromUrl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static String createXmlDocumentFromUrl(CommonInputs commonInputs) throws Exception {
              HttpClientService scoreHttpClient = new HttpClientService();
              HttpClientInputs httpClientInputs = new HttpClientInputs();
              httpClientInputs.setMethod(HttpGet.METHOD_NAME);
              httpClientInputs.setUrl(commonInputs.getXmlDocument());
      Severity: Minor
      Found in cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java - About 1 hr to fix

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

            public static InputStream getStream(String xml, String filePath) throws IOException {
                InputStream inputXML;
                if (StringUtils.isEmpty(filePath)) {
                    inputXML = new ByteArrayInputStream(xml.getBytes());
                } else {
        Severity: Minor
        Found in cs-xml/src/main/java/io/cloudslang/content/xml/utils/XmlUtils.java - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status