NationalGenomicsInfrastructure/ngi_pipeline

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

Summary

Maintainability
C
1 day
Test Coverage

Function parse_mean_coverage_from_qualimap has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def parse_mean_coverage_from_qualimap(piper_qc_dir, sample_id, seqrun_id=None, fcid=None):
    """This will return an integer value representing the total autosomal coverage
    for a particular sample OR seqrun (if seqrun_id is passed) as gleaned from
    the qualimapReport.html present in piper_qc_dir.

Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/parsers.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 parse_qualimap_coverage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def parse_qualimap_coverage(genome_results_file):
    autosomal_cov_length = 0
    autosomal_cov_bases = 0
    coverage_section = False
    with open(genome_results_file, 'r') as f:
Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/parsers.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 parse_genotype_concordance has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def parse_genotype_concordance(genotype_concordance_file):
    genotype_concordance_file = os.path.realpath(genotype_concordance_file)
    concordance_data = []
    gt_values_list = []
    with open(genotype_concordance_file, 'r') as f:
Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/parsers.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 parse_qualimap_reads has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def parse_qualimap_reads(genome_results_file):
    globals_section= False
    with open(genome_results_file, 'r') as f:
        for line in f:
            if line.startswith('>>>>>>> Globals'):
Severity: Minor
Found in ngi_pipeline/engines/piper_ngi/parsers.py - About 45 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 sections[0].isdigit() and int(sections[0]) <= 22:
                        autosomal_cov_length += float(sections[1])
                        autosomal_cov_bases += float(sections[2])
        if autosomal_cov_length and autosomal_cov_bases:
Severity: Major
Found in ngi_pipeline/engines/piper_ngi/parsers.py - About 45 mins to fix

    Function parse_deduplication_percentage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_deduplication_percentage(deduplication_file):
    
        duplication_percentage=0
        with open(deduplication_file, 'r') as f:
            for line in iter(f.readline, ''):
    Severity: Minor
    Found in ngi_pipeline/engines/piper_ngi/parsers.py - 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

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

        try:
            parser_function = getattr(sys.modules[__name__], parser_fn_name)
        except AttributeError as e:
            error_msg = 'Workflow "{}" has no associated parser implemented.'.format(workflow_name)
            LOG.error(error_msg)
    Severity: Major
    Found in ngi_pipeline/engines/piper_ngi/parsers.py and 2 other locations - About 2 hrs to fix
    ngi_pipeline/engines/piper_ngi/workflows.py on lines 65..70
    ngi_pipeline/engines/qc_ngi/workflows.py on lines 31..36

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

    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