CMSgov/dpc-app

View on GitHub
dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java

Summary

Maintainability
B
4 hrs
Test Coverage

Method fromCode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static DPCResourceType fromCode(String code) throws FHIRException {
        if ("Bundle".equals(code))
            return Bundle;
        if ("Coverage".equals(code))
            return Coverage;
Severity: Minor
Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.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

Avoid too many return statements within this method.
Open

            return Schedule;
Severity: Major
Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return Group;
    Severity: Major
    Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return Organization;
      Severity: Major
      Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return OperationOutcome;
        Severity: Major
        Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return Practitioner;
          Severity: Major
          Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return Patient;
            Severity: Major
            Found in dpc-common/src/main/java/gov/cms/dpc/fhir/DPCResourceType.java - About 30 mins to fix

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  OperationOutcome,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Bundle,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Endpoint,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Group,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Organization,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Coverage,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  ExplanationOfBenefit,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Practitioner,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Schedule;

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
              Open

                  Patient,

              Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

              Noncompliant Code Example

              With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

              public class MyClass {
                public static final int first = 1;
              }
              
              public enum MyEnum {
                first;
              }
              

              Compliant Solution

              public class MyClass {
                public static final int FIRST = 1;
              }
              
              public enum MyEnum {
                FIRST;
              }
              

              There are no issues that match your filters.

              Category
              Status