NationalGenomicsInfrastructure/ngi_pipeline

View on GitHub
ngi_pipeline/engines/piper_ngi/launchers.py

Summary

Maintainability
F
3 days
Test Coverage

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

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

"""The Piper automated launcher script."""
from __future__ import print_function

import glob
import os
Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 4 hrs to fix

    Function sbatch_piper_sample has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def sbatch_piper_sample(command_line_list, workflow_name, project, sample,
                            libprep=None, restart_finished_jobs=False, files_to_copy=None,
                            config=None, config_file_path=None):
        """sbatch a piper sample-level workflow.
    
    
    Severity: Minor
    Found in ngi_pipeline/engines/piper_ngi/launchers.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 sbatch_piper_sample has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def sbatch_piper_sample(command_line_list, workflow_name, project, sample,
                            libprep=None, restart_finished_jobs=False, files_to_copy=None,
                            config=None, config_file_path=None):
        """sbatch a piper sample-level workflow.
    
    
    Severity: Major
    Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 2 hrs to fix

      Function sbatch_piper_sample has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def sbatch_piper_sample(command_line_list, workflow_name, project, sample,
      Severity: Major
      Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 1 hr to fix

        Function collect_files_for_sample_analysis has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def collect_files_for_sample_analysis(project_obj, sample_obj, 
                                              restart_finished_jobs=False,
                                              status_field="alignment_status"):
            """This function finds all data files relating to a sample and
            follows a preset decision path to decide which of them to include in
        Severity: Minor
        Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 55 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

        Avoid deeply nested control flow statements.
        Open

                            if not analysis_object.restart_finished_jobs:
                                LOG.info('Project/sample "{}/{}" has completed genotype '
                                         'analysis previously; skipping (use flag to force '
                                         'analysis)'.format(analysis_object.project, sample))
                                continue
        Severity: Major
        Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for x in range(10):
                                      # Time delay to let sbatch get its act together
                                      # (takes a few seconds to be visible with sacct)
                                      try:
                                          get_slurm_job_status(slurm_job_id)
          Severity: Major
          Found in ngi_pipeline/engines/piper_ngi/launchers.py - About 45 mins to fix

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

                    try:
                        charon_reported_status = charon_session.sample_get(analysis_object.project.project_id,
                                                                           sample).get('analysis_status')
                        # Check Charon to ensure this hasn't already been processed
                        do_analyze=handle_sample_status(analysis_object, sample, charon_reported_status)
            Severity: Major
            Found in ngi_pipeline/engines/piper_ngi/launchers.py and 1 other location - About 1 hr to fix
            ngi_pipeline/engines/rna_ngi/launchers.py on lines 35..40

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

            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

                try:
                    slurm_job_id = re.match(r'Submitted batch job (\d+)', p_out).groups()[0]
                except AttributeError:
                    raise RuntimeError('Could not submit sbatch job for workflow "{}": '
                                       '{}'.format(job_identifier, p_err))
            Severity: Major
            Found in ngi_pipeline/engines/piper_ngi/launchers.py and 1 other location - About 1 hr to fix
            ngi_pipeline/engines/qc_ngi/launchers.py on lines 75..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 43.

            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_file_path = create_log_file_path(workflow_subtask=workflow_subtask,
                                                                     project_base_path=analysis_object.project.base_path,
                                                                     project_name=analysis_object.project.dirname,
                                                                     project_id=analysis_object.project.project_id,
                                                                     sample_id=sample.name)
            Severity: Minor
            Found in ngi_pipeline/engines/piper_ngi/launchers.py and 1 other location - About 55 mins to fix
            ngi_pipeline/engines/piper_ngi/launchers.py on lines 121..125

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

            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

                                exit_code_path = create_exit_code_file_path(workflow_subtask=workflow_subtask,
                                                                            project_base_path=analysis_object.project.base_path,
                                                                            project_name=analysis_object.project.dirname,
                                                                            project_id=analysis_object.project.project_id,
                                                                            sample_id=sample.name)
            Severity: Minor
            Found in ngi_pipeline/engines/piper_ngi/launchers.py and 1 other location - About 55 mins to fix
            ngi_pipeline/engines/piper_ngi/launchers.py on lines 115..119

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

            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

                try:
                    slurm_project_id = config["environment"]["project_id"]
                except KeyError:
                    raise RuntimeError('No SLURM project id specified in configuration file '
            Severity: Minor
            Found in ngi_pipeline/engines/piper_ngi/launchers.py and 1 other location - About 55 mins to fix
            ngi_pipeline/engines/qc_ngi/launchers.py on lines 106..109

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

            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