CMSgov/dpc-app

View on GitHub

Showing 316 of 391 total issues

Function UploadFileToS3 has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func UploadFileToS3(s *session.Session, fileName string, buff bytes.Buffer, s3Bucket string, s3Path string) error {
Severity: Minor
Found in lambda/opt-out-export/dpcaws/s3.go - About 35 mins to fix

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

        public Resource retrieveData(UUID organizationId, String orgNPI, String providerNPI, List<String> patientIds, DPCResourceType... resourceTypes) {
    Severity: Minor
    Found in dpc-queue/src/main/java/gov/cms/dpc/queue/service/DataService.java - About 35 mins to fix

      Method everything has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public abstract Resource everything(OrganizationPrincipal organization,
                                              @Valid @Profiled Provenance attestation,
                                              UUID patientId,
                                              @QueryParam("_since") @NoHtml String since,
                                              HttpServletRequest request);

        Method everything has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public Bundle everything(@ApiParam(hidden = true) @Auth OrganizationPrincipal organization,
                                     @Valid @Profiled @ProvenanceHeader Provenance provenance,
                                     @ApiParam(value = "Patient resource ID", required = true) @PathParam("patientID") UUID patientId,
                                     @QueryParam("_since") @NoHtml String sinceParam,
                                     @Context HttpServletRequest request) {
        Severity: Minor
        Found in dpc-api/src/main/java/gov/cms/dpc/api/resources/v1/PatientResource.java - About 35 mins to fix

          Method fetchBundle has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private <T extends IBaseResource> Bundle fetchBundle(Class<T> resourceClass,
                                                                   List<ICriterion<? extends IParam>> criteria,
                                                                   String patientID,
                                                                   DateRangeParam lastUpdated,
                                                                   Map<String, String> headers) {

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

                @Override
                public Bundle requestPatientFromServerByMbiHash(String mbiHash, Map<String, String> headers) throws ResourceNotFoundException {
                    String mbi = MBI_HASH_MAP.values().stream()
                            .filter(h -> h.equals(mbiHash))
                            .findFirst()
            dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/clientV2/MockBlueButtonClientV2.java on lines 80..87

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

            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

                @Override
                public Bundle requestPatientFromServerByMbiHash(String mbiHash, Map<String, String> headers) throws ResourceNotFoundException {
                    String mbi = MBI_HASH_MAP.values().stream()
                            .filter(h -> h.equals(mbiHash))
                            .findFirst()
            dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/MockBlueButtonClient.java on lines 88..95

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

            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

                    final Optional<Organization> optOrganization = transactionBundle
                            .getEntry()
                            .stream()
                            .filter(entry -> entry.hasResource() && entry.getResource().getResourceType().getPath().equals(DPCResourceType.Organization.getPath()))
                            .map(entry -> (Organization) entry.getResource())
            dpc-attribution/src/main/java/gov/cms/dpc/attribution/resources/v1/OrganizationResource.java on lines 173..177

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

            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

                    return transactionBundle
                            .getEntry()
                            .stream()
                            .filter(entry -> entry.hasResource() && entry.getResource().getResourceType().getPath().equals(DPCResourceType.Endpoint.getPath()))
                            .map(entry -> (Endpoint) entry.getResource())
            dpc-attribution/src/main/java/gov/cms/dpc/attribution/resources/v1/OrganizationResource.java on lines 94..98

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

            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 io.dropwizard.lifecycle.Managed;
            
            import javax.inject.Inject;
            dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/client/BlueButtonClientManager.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 46.

            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 io.dropwizard.lifecycle.Managed;
            
            import javax.inject.Inject;
            dpc-bluebutton/src/main/java/gov/cms/dpc/bluebutton/clientV2/BlueButtonClientManagerV2.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 46.

            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 handler has 5 return statements (exceeds 4 allowed).
            Open

            func handler(ctx context.Context, sqsEvent events.SQSEvent) (string, error) {
                log.SetFormatter(&log.JSONFormatter{
                    DisableHTMLEscape: true,
                    TimestampFormat:   time.RFC3339Nano,
                })
            Severity: Major
            Found in lambda/opt-out-import/main.go - About 35 mins to fix

              Method fromFhir has a Cognitive Complexity of 7 (exceeds 5 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);
                      }

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

              },{"object-assign":4,"receptor/behavior":5}],17:[function(require,module,exports){
              "use strict";
              
              // https://stackoverflow.com/a/7557433
              function isElementInViewport(el) {
              Severity: Minor
              Found in dpc-admin/app/assets/javascripts/components/_accordions.js - 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 19 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              },{}],19:[function(require,module,exports){
              'use strict';
              
              var EXPANDED = 'aria-expanded';
              var CONTROLS = 'aria-controls';
              Severity: Minor
              Found in dpc-admin/app/assets/javascripts/components/_accordions.js - 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

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

                  def destroy
                    if resource.destroy_with_password(user_params[:password_to_delete])
                      Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
                      flash[:notice] = 'Bye! Your account has been successfully cancelled. We hope to see you again soon.'
                      yield resource if block_given?
              Severity: Minor
              Found in dpc-web/app/controllers/users/registrations_controller.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

              Method buildRangedRequest has a Cognitive Complexity of 7 (exceeds 5 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();
              Severity: Minor
              Found in dpc-api/src/main/java/gov/cms/dpc/api/resources/v1/DataResource.java - 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 SaveDPCKeyPair has 5 return statements (exceeds 4 allowed).
              Open

              func SaveDPCKeyPair(prefix string, private *rsa.PrivateKey, public *rsa.PublicKey) error {
                  if private == nil || public == nil {
                      return errors.New("private and/or public key arguments cannot be nil")
                  }
                  if err := ValidateDPCKey(private); err != nil {
              Severity: Major
              Found in dpcclient/lib/pki.go - About 35 mins to fix

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

                func ParseSQSEvent(event events.SQSEvent) (*events.S3Event, error) {
                    var snsEntity events.SNSEntity
                    err := json.Unmarshal([]byte(event.Records[0].Body), &snsEntity)
                
                    unmarshalTypeErr := new(json.UnmarshalTypeError)
                Severity: Major
                Found in lambda/opt-out-import/parsers.go - About 35 mins to fix

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

                      @Override
                      @Path("/{fileID}.ndjson")
                      @GET
                      @Timed
                      @ExceptionMetered
                  Severity: Minor
                  Found in dpc-api/src/main/java/gov/cms/dpc/api/resources/v1/DataResource.java - 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

                  Severity
                  Category
                  Status
                  Source
                  Language