bel/nanopub/pubmed.py

Summary

Maintainability
C
7 hrs
Test Coverage

File pubmed.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

"""
Pubmed related utilities
Severity: Minor
Found in bel/nanopub/pubmed.py - About 2 hrs to fix

    Function add_annotations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_annotations(pubmed):
        """Add nanopub annotations to pubmed doc
    
        Enhance MESH terms etc as full-fledged nanopub annotations for use by the BEL Nanopub editor
        """
    Severity: Minor
    Found in bel/nanopub/pubmed.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_journal_article_record has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_journal_article_record(doc: dict, root) -> dict:
        """Parse Pubmed Journal Article record"""
    
        doc["title"] = next(iter(root.xpath("//ArticleTitle/text()")), "")
    
    
    Severity: Minor
    Found in bel/nanopub/pubmed.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 process_pub_date has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def process_pub_date(year, mon, day, medline_date):
        """Create pub_date from what Pubmed provides in Journal PubDate entry"""
    
        if medline_date:
            year = "0000"
    Severity: Minor
    Found in bel/nanopub/pubmed.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_book_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_book_record(doc: dict, root) -> dict:
        """Parse Pubmed Book entry"""
    
        doc["title"] = next(iter(root.xpath("//BookTitle/text()")))
    
    
    Severity: Minor
    Found in bel/nanopub/pubmed.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

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

    def get_pubtator(pmid):
        """Get Pubtator Bioconcepts from Pubmed Abstract
    
        Re-configure the denotations into an annotation dictionary format
        and collapse duplicate terms so that their spans are in a list.
    Severity: Minor
    Found in bel/nanopub/pubmed.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

    There are no issues that match your filters.

    Category
    Status