CMSgov/dpc-app

View on GitHub

Showing 315 of 390 total issues

Method processJobBatchPartial has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public List<JobQueueBatchFile> processJobBatchPartial(UUID aggregatorID, IJobQueue queue, JobQueueBatch job, String mbi) {
        StopWatch stopWatch = StopWatch.createStarted();
        Optional<OutcomeReason> failReason = Optional.empty();
        Optional<Flowable<Resource>> flowable = Optional.empty();

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

Consider simplifying this complex logical expression.
Open

  if (!("classList" in document.createElement("_")) || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g"))) {

    (function (view) {

      "use strict";
Severity: Critical
Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

    Method API.RunGroupTests has 66 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

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

      Method fromFHIR has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

          @Override
          public OrganizationEntity fromFHIR(FHIREntityConverter converter, Organization resource) {
              final OrganizationEntity entity = new OrganizationEntity();
      
              // Add the profile metadata

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

                private void refreshAuthToken() {
                    System.out.println("Refreshing access token");
                    try {
                        final AuthResponse authResponse = jwtAuthFlow(this.baseURL, this.clientToken, this.keyID, this.privateKey);
                        // Set the refresh time to be 30 seconds before expiration
        dpc-testing/src/main/java/gov/cms/dpc/testing/APIAuthHelpers.java on lines 460..472

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

        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

                private void refreshAuthToken() {
                    System.out.println("Refreshing access token");
                    try {
                        final AuthResponse authResponse = jwtAuthFlow(this.baseURL, this.clientToken, this.keyID, this.privateKey);
                        // Set the refresh time to be 30 seconds before expiration
        dpc-testing/src/main/java/gov/cms/dpc/testing/APIAuthHelpers.java on lines 417..429

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

        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 9 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        },{"../compose":6,"../delegate":7}],9:[function(require,module,exports){
        'use strict';
        
        function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
        
        
        Severity: Minor
        Found in dpc-admin/app/assets/javascripts/components/_accordions.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 checkJobStatus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            @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

        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 18 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        },{}],18:[function(require,module,exports){
        'use strict';
        
        var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
        
        
        Severity: Minor
        Found in dpc-admin/app/assets/javascripts/components/_accordions.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 everything has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @GET
            @FHIR
            @Path("/{patientID}/$everything")
            @PathAuthorizer(type = DPCResourceType.Patient, pathParam = "patientID")
            @Timed

          Method processJobBatch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Trace
              protected void processJobBatch(JobQueueBatch job) {
                  final String queueCompleteTime = SplunkTimestamp.getSplunkTimestamp();
                  try {
                      MDC.put(MDCConstants.JOB_ID, job.getJobID().toString());

            Method buildRangedRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private Response buildRangedRequest(String fileID, File file, RangeHeader range) {
                    if (!range.getUnit().equals(ACCEPTED_RANGE_VALUE)) {
                        throw new WebApplicationException("Only `bytes` are acceptable as ranges", Response.Status.REQUESTED_RANGE_NOT_SATISFIABLE);
                    }
                    final long rangeStart = range.getStart() < 0 ? 0 : range.getStart();

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

              function removeElementsByClass(className){
                var elements = document.getElementsByClassName(className);
                while(elements.length > 0){
                    elements[0].parentNode.removeChild(elements[0]);
                }
              Severity: Major
              Found in dpc-admin/app/assets/javascripts/components/navbar.js and 1 other location - About 1 hr to fix
              dpc-web/app/assets/javascripts/components/navbar.js on lines 10..15

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

              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

              function removeElementsByClass(className){
                var elements = document.getElementsByClassName(className);
                while(elements.length > 0){
                    elements[0].parentNode.removeChild(elements[0]);
                }
              Severity: Major
              Found in dpc-web/app/assets/javascripts/components/navbar.js and 1 other location - About 1 hr to fix
              dpc-admin/app/assets/javascripts/components/navbar.js on lines 10..15

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

              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 importResponseFile has 14 return statements (exceeds 4 allowed).
              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: Major
              Found in lambda/opt-out-import/main.go - About 1 hr to fix

                Method registerOrganization has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static String registerOrganization(IGenericClient client, IParser parser, String organizationID, String organizationNPI, String adminURL) throws IOException {
                        // Random number generator for Org NPI
                        // Register an organization, and a token
                        // Read in the test file
                        String macaroon;
                Severity: Minor
                Found in dpc-common/src/main/java/gov/cms/dpc/fhir/helpers/FHIRHelpers.java - About 1 hr to fix

                  Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Override
                      public void initialize(Bootstrap<DPCConsentConfiguration> bootstrap) {
                          JerseyGuiceUtils.reset();
                  
                          // Enable variable substitution with environment variables

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

                                try (CloseableHttpResponse response = httpClient.execute(post)) {
                                    if (!HttpStatus.isSuccess(response.getStatusLine().getStatusCode())) {
                                        System.err.println("Error fetching organization: " + response.getStatusLine().getReasonPhrase());
                                        System.exit(1);
                                    }
                    dpc-api/src/main/java/gov/cms/dpc/api/cli/tokens/TokenCreate.java on lines 72..79

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

                    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 (CloseableHttpResponse response = httpClient.execute(post)) {
                                    if (!HttpStatus.isSuccess(response.getStatusLine().getStatusCode())) {
                                        System.err.println("Error fetching organization: " + response.getStatusLine().getReasonPhrase());
                                        System.exit(1);
                                    }
                    dpc-api/src/main/java/gov/cms/dpc/api/cli/keys/KeyUpload.java on lines 100..107

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

                    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

                    module RedisStore
                      class MailThrottleStore
                        # Redis interface for rate limiting user mail
                    
                        NAMESPACE = 'mail_throttle'
                    Severity: Major
                    Found in dpc-admin/lib/redis_store/mail_throttle_store.rb and 1 other location - About 1 hr to fix
                    dpc-web/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

                    Severity
                    Category
                    Status
                    Source
                    Language