HumanCellAtlas/ingest-core

View on GitHub

Showing 14 of 78 total issues

SubmissionController has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

@RepositoryRestController
@ExposesResourceFor(SubmissionEnvelope.class)
@RequiredArgsConstructor
@Getter
public class SubmissionController {

    QueueConfig has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @Configuration
    public class QueueConfig implements RabbitListenerConfigurer {
        @Bean Queue queueFileUpdate() { return new Queue(Constants.Queues.FILE_UPDATE, false); }
    
        @Bean Queue queueBundleUpdate() { return new Queue(Constants.Routing.UPDATE_SUBMITTED, true); }
    Severity: Minor
    Found in src/main/java/org/humancellatlas/ingest/messaging/QueueConfig.java - About 3 hrs to fix

      Method cleanupLinksToSubmissionMetadata has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void cleanupLinksToSubmissionMetadata(SubmissionEnvelope submissionEnvelope) {
              long startTime = System.currentTimeMillis();
      
              processRepository.findBySubmissionEnvelope(submissionEnvelope)
                               .forEach(p -> {

        Method findByCriteria has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public Page<Project> findByCriteria(List<MetadataCriteria> criteriaList, Boolean andCriteria, Pageable pageable) {
                Query query = new Query();
                
                List<Criteria> criterias = new ArrayList<>();

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

              public static List<SubmissionState> allowedStateTransitions(SubmissionState fromState) {
                  List<SubmissionState> allowedStates = new ArrayList<>();
                  switch (fromState) {
                      case PENDING:
                          allowedStates.add(SubmissionState.DRAFT);

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

                private Iterator<BundleManifest> allManifestsIterator() {
                    Iterator<BundleManifest> manifestsIterator = new Iterator<BundleManifest>() {
                        Pageable pageable = new PageRequest(0, 5000);
                        Page<BundleManifest> pagedBundleManifests = null;
                        Queue<BundleManifest> bundleManifests;

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

                  public Map<String, Set<MetadataDocument>> bundleManifestsForDocuments(Collection<MetadataDocument> documents) {
              
                      Map<String, Set<MetadataDocument>> hits = new HashMap<>();
              
                      long fileStartTime = System.currentTimeMillis();

                Method allManifestsIterator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private Iterator<BundleManifest> allManifestsIterator() {
                        Iterator<BundleManifest> manifestsIterator = new Iterator<BundleManifest>() {
                            Pageable pageable = new PageRequest(0, 5000);
                            Page<BundleManifest> pagedBundleManifests = null;
                            Queue<BundleManifest> bundleManifests;

                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 querySchemas has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    Page<Schema> querySchemas(@Param("high-level-entity") String highLevelEntity,
                                              @Param("concrete-entity") String concreteEntity,
                                              @Param("domain-entity") String domainEntity,
                                              @Param("sub-domain-entity") String subDomainEntity,
                                              @Param("schema-version") String schemaVersion,
                Severity: Minor
                Found in src/main/java/org/humancellatlas/ingest/schemas/SchemaRepository.java - About 45 mins to fix

                  Method getFeatureCompatibilityVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static ServerVersion getFeatureCompatibilityVersion(MongoDatabase db) {
                          Document response = db.runCommand(new Document("getParameter", 1).append("featureCompatibilityVersion", 1));
                          if (response.containsKey("ok") && response.containsKey("featureCompatibilityVersion")) {
                              if (getServerVersion(db).compareTo(getVersionFromString("3.6")) < 0)
                                  return  getVersionFromString(response.getString("featureCompatibilityVersion"));

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

                      @Override
                      public Page<Project> findByCriteria(List<MetadataCriteria> criteriaList, Boolean andCriteria, Pageable pageable) {
                          Query query = new Query();
                          
                          List<Criteria> criterias = new ArrayList<>();

                  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 Optional.ofNullable(bundleManifest.getFileBiomaterialMap());

                    Method entityMapFromManifest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private Optional<Map<String, Collection<String>>> entityMapFromManifest(EntityType entityType, BundleManifest bundleManifest) {
                            if(entityType.equals(EntityType.BIOMATERIAL)) {
                                return Optional.ofNullable(bundleManifest.getFileBiomaterialMap());
                            } else if(entityType.equals(EntityType.FILE)) {
                                return Optional.ofNullable(bundleManifest.getFileFilesMap());

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

                        @RabbitListener(queues = Constants.Queues.FILE_STAGED)
                        public void handleFileStagedEvent(FileMessage fileMessage) {
                            if(!StringUtils.isEmpty(fileMessage.getContentType())
                                    && fileMessage.getMediaType().isPresent()
                                    && fileMessage.getMediaType().get().equals(FileMediaTypes.HCA_DATA_FILE)){
                    Severity: Minor
                    Found in src/main/java/org/humancellatlas/ingest/file/web/FileListener.java - About 25 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