NationalGenomicsInfrastructure/ngi_pipeline

View on GitHub

Showing 242 of 242 total issues

Function update_charon_with_local_jobs_status has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

def update_charon_with_local_jobs_status(quiet=False, config=None, config_file_path=None):
    """Check the status of all locally-tracked jobs and update Charon accordingly.
    """
    if quiet and not config.get("quiet"):
        config['quiet'] = True
Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/local_process_tracking.py - About 2 days 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 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

Function analyze has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

def analyze(analysis_object, level='sample', config=None, config_file_path=None):
    """Analyze data at the sample level.

    :param NGIAnalysis analysis_object: holds all the parameters for the analysis

Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/launchers.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

Function create_charon_entries_from_project has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

def create_charon_entries_from_project(project, best_practice_analysis="whole_genome_reseq",
                                       sequencing_facility="NGI-S",
                                       force_overwrite=False,
                                       retry_on_fail=True):
    """Given a project object, creates the relevant entries in Charon.
Severity: Minor
Found in ngi_pipeline/database/filesystem.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 local_process_tracking.py has 543 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import glob
import inspect
import os
import psutil
Severity: Major
Found in ngi_pipeline/engines/piper_ngi/local_process_tracking.py - About 1 day to fix

    File sarek.py has 486 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import csv
    import os
    
    from ngi_pipeline.engines.sarek.database import CharonConnector, TrackingConnector
    from ngi_pipeline.engines.sarek.exceptions import BestPracticeAnalysisNotRecognized, SampleNotValidForAnalysisError
    Severity: Minor
    Found in ngi_pipeline/engines/sarek/models/sarek.py - About 7 hrs to fix

      File gt_concordance.py has 475 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      from __future__ import print_function
      import sys
      import os
      import re
      Severity: Minor
      Found in scripts/gt_concordance.py - About 7 hrs to fix

        Function analyze has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

        def analyze(analysis_object, config=None, config_file_path=None):
        
            charon_session = CharonSession()
            charon_pj=charon_session.project_get(analysis_object.project.project_id)
            reference_genome=charon_pj.get('reference')
        Severity: Minor
        Found in ngi_pipeline/engines/rna_ngi/launchers.py - About 7 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 recreate_project_from_filesystem has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        def recreate_project_from_filesystem(project_dir,
                                             restrict_to_samples=None,
                                             restrict_to_libpreps=None,
                                             restrict_to_seqruns=None,
                                             config=None, config_file_path=None):
        Severity: Minor
        Found in ngi_pipeline/utils/filesystem.py - About 5 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

        File utils.py has 397 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import collections
        import datetime
        import fnmatch
        import glob
        import os
        Severity: Minor
        Found in ngi_pipeline/engines/piper_ngi/utils.py - About 5 hrs to fix

          File parsers.py has 376 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import collections
          import csv
          import glob
          import gzip
          import os
          Severity: Minor
          Found in ngi_pipeline/utils/parsers.py - About 5 hrs to fix

            File launchers.py has 371 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """The Piper automated launcher script."""
            from __future__ import print_function
            
            import collections
            import glob
            Severity: Minor
            Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 4 hrs to fix

              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

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

                    def __init__(self, path):
                        """
                        Creates a Runfolder object representing a runfolder directory.
                
                        :param path: the path to the runfolder where the name will be used to identify properties
                Severity: Major
                Found in ngi_pipeline/engines/sarek/models/resources.py and 1 other location - About 4 hrs to fix
                ngi_pipeline/engines/sarek/models/resources.py on lines 15..28

                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

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

                    def __init__(self, path):
                        """
                        Creates a SampleFastq object representing a fastq file.
                
                        :param path: the path to the fastq file, where the file name will be used to identify properties
                Severity: Major
                Found in ngi_pipeline/engines/sarek/models/resources.py and 1 other location - About 4 hrs to fix
                ngi_pipeline/engines/sarek/models/resources.py on lines 76..89

                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

                Function launch_analysis has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                def launch_analysis(projects_to_analyze, restart_failed_jobs=False,
                                    restart_finished_jobs=False, restart_running_jobs=False,
                                    no_qc=False, exec_mode="sbatch",
                                    quiet=False, manual=False,
                                    config=None, config_file_path=None):
                Severity: Minor
                Found in ngi_pipeline/conductor/launchers.py - About 4 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 genotype_project has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                def genotype_project(context, project, force):
                    config = context.obj
                    if is_config_file_ok():
                        output_path = os.path.join(config.get('ANALYSIS_PATH'), project, 'piper_ngi/03_genotype_concordance')
                        if not os.path.exists(output_path):
                Severity: Minor
                Found in scripts/gt_concordance.py - About 4 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

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

                        for sample_file in sample_files:
                            LOG.debug("Deleting file {}".format(sample_file))
                            try:
                                if os.path.isdir(sample_file):
                                    shutil.rmtree(sample_file)
                Severity: Major
                Found in ngi_pipeline/engines/piper_ngi/utils.py and 1 other location - About 4 hrs to fix
                ngi_pipeline/engines/piper_ngi/utils.py on lines 140..148

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

                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

                        for sample_file in sample_files:
                            LOG.info("Deleting file {}".format(sample_file))
                            try:
                                if os.path.isdir(sample_file):
                                    shutil.rmtree(sample_file)
                Severity: Major
                Found in ngi_pipeline/engines/piper_ngi/utils.py and 1 other location - About 4 hrs to fix
                ngi_pipeline/engines/piper_ngi/utils.py on lines 109..117

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

                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

                File filesystem.py has 336 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from __future__ import print_function
                
                import collections
                import contextlib
                import datetime
                Severity: Minor
                Found in ngi_pipeline/utils/filesystem.py - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language