CMSgov/dpc-app

View on GitHub

Showing 316 of 391 total issues

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

module RedisStore
  class MailThrottleStore
    # Redis interface for rate limiting user mail

    NAMESPACE = 'mail_throttle'
Severity: Major
Found in dpc-web/lib/redis_store/mail_throttle_store.rb and 1 other location - About 1 hr to fix
dpc-admin/lib/redis_store/mail_throttle_store.rb on lines 5..32

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

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

Function searchFunc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function searchFunc() {
  var input, filter, ul, li, i, txtValue, div;
  input = document.getElementById('searchInput');
  filter = input.value.toUpperCase();
  ul = document.getElementById('searchList');
Severity: Minor
Found in dpc-admin/app/assets/javascripts/components/_add-user-search.js - About 1 hr to fix

    Function shouldUseNative has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function shouldUseNative() {
      try {
        if (!Object.assign) {
          return false;
        }
    Severity: Minor
    Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

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

        def create_api_organization
          api_request = api_service.create_organization(
            organization,
            fhir_endpoint: fhir_endpoint.attributes.slice('name', 'status', 'uri')
          )
      Severity: Major
      Found in dpc-admin/app/models/registered_organization.rb and 1 other location - About 1 hr to fix
      dpc-web/app/models/registered_organization.rb on lines 32..48

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

      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

        def create_api_organization
          api_request = api_service.create_organization(
            organization,
            fhir_endpoint: fhir_endpoint.attributes.slice('name', 'status', 'uri')
          )
      Severity: Major
      Found in dpc-web/app/models/registered_organization.rb and 1 other location - About 1 hr to fix
      dpc-admin/app/models/registered_organization.rb on lines 32..48

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

      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

          @SuppressWarnings("JdkObsolete") // Date class is used by HAPI FHIR DateRangeParam
          private boolean isInDateRange(DateRangeParam range) {
              if (range == null) return true;
              final var upperBound = range.getUpperBoundAsInstant();
              final var lowerBound = range.getLowerBoundAsInstant();
      dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/MockBlueButtonClient.java on lines 193..200

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

      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

          @SuppressWarnings("JdkObsolete") // Date class is used by HAPI FHIR DateRangeParam
          private boolean isInDateRange(DateRangeParam range) {
              if (range == null) return true;
              final var upperBound = range.getUpperBoundAsInstant();
              final var lowerBound = range.getLowerBoundAsInstant();
      dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/clientV2/MockBlueButtonClientV2.java on lines 177..184

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

      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

      Method retrieveData has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public Resource retrieveData(UUID organizationID,
                                       String orgNPI,
                                       String providerNPI,
                                       List<String> patientMBIs,
                                       OffsetDateTime since,
      Severity: Major
      Found in dpc-queue/src/main/java/gov/cms/dpc/queue/service/DataService.java - About 1 hr to fix

        Method replaceRoster has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @PUT
            @Path("/{rosterID}")
            @FHIR
            @UnitOfWork
            @Override

          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

          Function searchFunc has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function searchFunc() {
            var input, filter, ul, li, i, txtValue, div;
            input = document.getElementById('searchInput');
            filter = input.value.toUpperCase();
            ul = document.getElementById('searchList');
          Severity: Minor
          Found in dpc-admin/app/assets/javascripts/components/_add-user-search.js - 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 authenticate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Confirmed

              @Override
              public Optional<OrganizationPrincipal> authenticate(DPCAuthCredentials credentials) {
                  logger.debug("Performing token authentication");
          
                  // If we don't have a path authorizer, just return the principal

            Method checkJobStatus has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                @Path("/{jobID}")
                @GET
                @Timed
                @ExceptionMetered
            Severity: Minor
            Found in dpc-api/src/main/java/gov/cms/dpc/api/resources/v1/JobResource.java - About 1 hr to fix

              Method fromFhir has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("JdkObsolete") // Date class is used by FHIR stu3 Consent model
                  public static ConsentEntity fromFhir(Consent consent) {
                      if (consent == null) {
                          throw new WebApplicationException("No consent resource provided", Response.Status.BAD_REQUEST);
                      }

                Method API.RunTokenTests has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (api *API) RunTokenTests() {
                    const endpoint = "Token"
                
                    // Create organization (and delete at the end) and setup accesstoken
                    auth := api.SetUpOrgAuth()
                Severity: Minor
                Found in dpc-testing/performance/pkg/dpc/test_token.go - About 1 hr to fix

                  Method equals has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Override
                      public boolean equals(Object o) {
                          if (this == o) return true;
                  
                          if (!(o instanceof JobQueueBatch)) return false;
                  Severity: Minor
                  Found in dpc-queue/src/main/java/gov/cms/dpc/queue/models/JobQueueBatch.java - About 1 hr to fix

                    Function getListeners has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var getListeners = function getListeners(type, handler) {
                      var match = type.match(DELEGATE_PATTERN);
                      var selector;
                      if (match) {
                        type = match[1];
                    Severity: Minor
                    Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

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

                          public static final Map<String, String> MBI_BENE_ID_MAP = Map.of(
                                  TEST_PATIENT_MBIS.get(0), "-20140000008325",
                                  TEST_PATIENT_MBIS.get(1), "-20140000009893",
                                  TEST_PATIENT_MBIS.get(2), "-19990000002208",
                                  TEST_PATIENT_MBIS.get(3), "-19990000002209",
                      dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/MockBlueButtonClient.java on lines 48..58

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

                      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

                          public static final Map<String, String> MBI_HASH_MAP = Map.of(
                                  TEST_PATIENT_MBIS.get(0), "abadf57ff8dc94610ca0d479feadb1743c9cd3c77caf1eafde5719a154379fb6",
                                  TEST_PATIENT_MBIS.get(1), "8930cab29ba5fe4311a5f5bcfd5b7384f3722b711402aacf796d2ae6fea54242",
                                  TEST_PATIENT_MBIS.get(2), "e411277fd31da392eaa9a45df53b0c429e365626182f50d9f35810d77f0e2756",
                                  TEST_PATIENT_MBIS.get(3), "41af07535e0a66226cf2f0e6c551c0a15bd49192fc055aa5cd2e63f31f90a419",
                      dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/MockBlueButtonClient.java on lines 38..47

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

                      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

                          remove: function removeBehavior(element) {
                            listeners.forEach(function (listener) {
                              element.removeEventListener(listener.type, listener.delegate, listener.options);
                            });
                          }
                      Severity: Major
                      Found in dpc-admin/app/assets/javascripts/components/_accordions.js and 1 other location - About 1 hr to fix
                      dpc-admin/app/assets/javascripts/components/_accordions.js on lines 439..443

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

                      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