NationalGenomicsInfrastructure/ngi_pipeline

View on GitHub
ngi_pipeline/conductor/flowcell.py

Summary

Maintainability
F
4 days
Test Coverage

Function setup_analysis_directory_structure has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
Open

def setup_analysis_directory_structure(fc_dir, projects_to_analyze,
                                       restrict_to_projects=None, restrict_to_samples=None,
                                       create_files=True,
                                       fallback_libprep=None,
                                       quiet=False,
Severity: Minor
Found in ngi_pipeline/conductor/flowcell.py - About 1 day 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

File flowcell.py has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-


from __future__ import print_function
Severity: Minor
Found in ngi_pipeline/conductor/flowcell.py - About 4 hrs to fix

    Function parse_flowcell has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_flowcell(fc_dir):
        """
        Traverse a CASAVA-1.8 or 2.5 generated directory structure for the HiSeq 2500
        and return a dictionary of the elements it contains.
    
    
    Severity: Minor
    Found in ngi_pipeline/conductor/flowcell.py - About 3 hrs 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 setup_analysis_directory_structure has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def setup_analysis_directory_structure(fc_dir, projects_to_analyze,
    Severity: Major
    Found in ngi_pipeline/conductor/flowcell.py - About 1 hr to fix

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

      def organize_projects_from_flowcell(demux_fcid_dirs, restrict_to_projects=None,
                                          restrict_to_samples=None,
                                          fallback_libprep=None, quiet=False,
                                          create_files=True,
                                          config=None, config_file_path=None):
      Severity: Minor
      Found in ngi_pipeline/conductor/flowcell.py - 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 organize_projects_from_flowcell has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def organize_projects_from_flowcell(demux_fcid_dirs, restrict_to_projects=None,
      Severity: Major
      Found in ngi_pipeline/conductor/flowcell.py - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            for seqrun_obj in libprep_obj:
                                src_fastq_files = [os.path.join(src_sample_dir, fastq_file) for
                                                   fastq_file in seqrun_obj.fastq_files]
                                seqrun_dst_dir = os.path.join(project_obj.base_path, "DATA", project_obj.dirname,
                                                              sample_obj.dirname, libprep_obj.dirname,
        Severity: Major
        Found in ngi_pipeline/conductor/flowcell.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if len(libpreps) == 1:
                                      libprep_name = libpreps[0].get('libprepid')
                                      LOG.warning('Project "{}" / sample "{}" / seqrun "{}" / fastq "{}" '
                                               'has no libprep information in Charon, but only one '
                                               'library prep is present in Charon ("{}"). Using '
          Severity: Major
          Found in ngi_pipeline/conductor/flowcell.py - About 45 mins to fix

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

                def _is_a_match(ss_sample, prjid, sname, lnum, snum):
            Severity: Minor
            Found in ngi_pipeline/conductor/flowcell.py - About 35 mins to fix

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

                      LOG.info('Parsing project directory "{}"...'.format(
                                          project_dir.split(os.path.split(fc_dir)[0] + "/")[1]))
              Severity: Major
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 1 hr to fix
              ngi_pipeline/conductor/flowcell.py on lines 397..398

              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

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

                          LOG.info('Parsing samples directory "{}"...'.format(sample_dir.split(
                                                              os.path.split(fc_dir)[0] + "/")[1]))
              Severity: Major
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 1 hr to fix
              ngi_pipeline/conductor/flowcell.py on lines 390..391

              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

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

                          if not project_dir == project_sl_dir and \
                             not os.path.exists(project_sl_dir):
                              os.symlink(project_dir, project_sl_dir)
              Severity: Major
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 1 hr to fix
              ngi_pipeline/conductor/flowcell.py on lines 226..228

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

              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

                          if not project_analysis_dir == project_analysis_sl_dir and \
                             not os.path.exists(project_analysis_sl_dir):
                              os.symlink(project_analysis_dir, project_analysis_sl_dir)
              Severity: Major
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 1 hr to fix
              ngi_pipeline/conductor/flowcell.py on lines 223..225

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

              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 4 locations. Consider refactoring.
              Open

                          if restrict_to_samples and sample_name not in restrict_to_samples:
                              LOG.debug("Skipping sample {}: not in specified samples "
                                        "{}".format(sample_name, ", ".join(restrict_to_samples)))
                              continue
              Severity: Major
              Found in ngi_pipeline/conductor/flowcell.py and 3 other locations - About 1 hr to fix
              ngi_pipeline/utils/filesystem.py on lines 297..300
              ngi_pipeline/utils/filesystem.py on lines 310..313
              ngi_pipeline/utils/filesystem.py on lines 324..327

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

              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

                                          if not config.get('quiet'):
                                              mail_analysis(project_name=project_name,
              Severity: Minor
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 30 mins to fix
              ngi_pipeline/conductor/flowcell.py on lines 338..339

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

              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

                                          if not config.get('quiet'):
                                              mail_analysis(project_name=project_name,
              Severity: Minor
              Found in ngi_pipeline/conductor/flowcell.py and 1 other location - About 30 mins to fix
              ngi_pipeline/conductor/flowcell.py on lines 301..302

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

              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

              There are no issues that match your filters.

              Category
              Status