CMSgov/dpc-app

View on GitHub

Showing 316 of 391 total issues

Method check_sanctions_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def check_sanctions_response(response)
    return false if waiver?(response.dig('provider', 'waiverInfo'))

    med_sanctions_records = response.dig('provider', 'medSanctions')
    unless med_sanctions_records.nil? || med_sanctions_records.empty?
Severity: Minor
Found in dpc-portal/app/services/ao_verification_service.rb - About 35 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

Function importResponseFile has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func importResponseFile(bucket string, file string) (int, int, string, error) {
    log.Infof("Importing opt out file: %s (bucket: %s)", file, bucket)
    metadata, err := ParseMetadata(bucket, file)
    if err != nil {
        log.Warningf("Failed to parse opt out file metadata: %s", err)
Severity: Minor
Found in lambda/opt-out-import/main.go - About 35 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

Function insertConsentRecords has 5 return statements (exceeds 4 allowed).
Open

func insertConsentRecords(db *sql.DB, optOutFileId string, records []*OptOutRecord) ([]*OptOutRecord, error) {
    createdRecords := []*OptOutRecord{}

    // If there aren't any rows, skip this and update the import_status of the file
    if len(records) > 0 {
Severity: Major
Found in lambda/opt-out-import/db.go - About 35 mins to fix

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

      config.action_mailer.smtp_settings = {
        address:              ENV['SMTP_ADDRESS'],
        port:                 ENV['SMTP_PORT'],
        domain:               ENV['SMTP_DOMAIN'],
        user_name:            ENV['SMTP_USER_NAME'],
    Severity: Minor
    Found in dpc-admin/config/environments/production.rb and 1 other location - About 35 mins to fix
    dpc-web/config/environments/production.rb on lines 88..97

    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 34.

    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

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

      config.action_mailer.smtp_settings = {
        address:              ENV['SMTP_ADDRESS'],
        port:                 ENV['SMTP_PORT'],
        domain:               ENV['SMTP_DOMAIN'],
        user_name:            ENV['SMTP_USER_NAME'],
    Severity: Minor
    Found in dpc-web/config/environments/production.rb and 1 other location - About 35 mins to fix
    dpc-admin/config/environments/production.rb on lines 85..94

    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 34.

    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

    package gov.cms.dpc.bluebutton.client;
    
    
    import ca.uhn.fhir.rest.param.DateRangeParam;
    import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
    dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/clientV2/BlueButtonClientV2.java on lines 1..31

    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 43.

    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

    package gov.cms.dpc.bluebutton.clientV2;
    
    
    import ca.uhn.fhir.rest.param.DateRangeParam;
    import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
    dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/BlueButtonClient.java on lines 1..31

    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 43.

    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

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

            try {
                m1 = MacaroonBakery.deserializeMacaroon(macaroon);
            } catch (BakeryException e) {
                logger.error("Cannot deserialize Macaroon", e);
                throw new WebApplicationException(unauthorizedHandler.buildResponse(BEARER_PREFIX, realm));
    dpc-api/src/main/java/gov/cms/dpc/api/auth/DPCAuthFilter.java on lines 81..86

    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 42.

    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

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

            try {
                m1 = MacaroonBakery.deserializeMacaroon(macaroon);
            } catch (BakeryException e) {
                logger.error("Cannot deserialize Macaroon", e);
                throw new WebApplicationException(dpc401handler.buildResponse(BEARER_PREFIX, realm));
    Severity: Minor
    Found in dpc-api/src/main/java/gov/cms/dpc/api/auth/DPCAuthFilter.java and 1 other location - About 30 mins to fix
    dpc-api/src/main/java/gov/cms/dpc/api/auth/filters/AdminAuthFilter.java on lines 44..49

    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 42.

    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

            String eobOrganizationNPI = Optional.of(explanationOfBenefit)
                    .map(ExplanationOfBenefit::getOrganization)
                    .map(Reference::getIdentifier)
                    .filter(i -> DPCIdentifierSystem.NPPES.getSystem().equals(i.getSystem()))
                    .map(Identifier::getValue)
    dpc-aggregation/src/main/java/gov/cms/dpc/aggregation/service/LookBackServiceImpl.java on lines 72..76

    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 42.

    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

            String providerNPI = Optional.ofNullable(explanationOfBenefit)
                    .map(ExplanationOfBenefit::getProvider)
                    .map(Reference::getIdentifier)
                    .filter(i -> DPCIdentifierSystem.NPPES.getSystem().equals(i.getSystem()))
                    .map(Identifier::getValue)
    dpc-aggregation/src/main/java/gov/cms/dpc/aggregation/service/LookBackServiceImpl.java on lines 48..52

    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 42.

    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

    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 function.
      Open

          return true;
      Severity: Major
      Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return false;
        Severity: Major
        Found in dpc-admin/app/assets/javascripts/components/_accordions.js - 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

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

                            final String macaroon = MacaroonsBuilder
                                    .modify(MacaroonsBuilder.deserialize(goldenMacaroon).get(0))
                                    .add_first_party_caveat(String.format("organization_id = %s", organizationID))
                                    .getMacaroon().serialize(MacaroonVersion.SerializationVersion.V2_JSON);
                    dpc-smoketest/src/main/java/gov/cms/dpc/testing/smoketests/SmokeTest.java on lines 285..288

                    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 40.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language