savkov/bratutils

View on GitHub

Showing 24 of 45 total issues

File agreement.py has 755 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import glob
import ntpath
import logging

Severity: Major
Found in src/bratutils/agreement.py - About 1 day to fix

    File bratdata.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    __author__ = 'Aleksandar Savkov'
    
    """This module holds data structure classes and relevant methods for parsing
    and manipulating brat annotation files.0
    """
    Severity: Minor
    Found in src/bratutils/bratdata.py - About 3 hrs to fix

      Annotation has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Annotation:
          """Annotation data structure encoding the tag and position of an
          annotation, along with information about its comparison status.
          """
      
      
      Severity: Minor
      Found in src/bratutils/agreement.py - About 2 hrs to fix

        Function merge_brat_dox_dir has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def merge_brat_dox_dir(dp_a, dp_b, dp_res):
            """Merges the annotation files across all subdirectories of `dp_a` and
            `dp_b`, deploying the results in `dp_res`.
        
            :param dp_a: directory path A
        Severity: Minor
        Found in src/bratutils/utils.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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, fp=None, ann_list=None):
                """Constructs a `Document` object from an annotation file using `fp` or
                using a collection of Annotation objects in `ann_list`.
        
                :param fp: annotation document file path
        Severity: Minor
        Found in src/bratutils/agreement.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 _filter_borders has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _filter_borders(self, document):
                new_tags = []
                for tag in document.postag_list:
                    for condition in self.conditions:
                        in_range = tag.in_range(condition)
        Severity: Minor
        Found in src/bratutils/agreement.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 validate_indices has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_indices(self):
                """Validates the annotation indices in this document.
        
        
                :return: True if indices are correct
        Severity: Minor
        Found in src/bratutils/bratdata.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 handle_containing_tags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_containing_tags(tag, ctags, muc):
                for ctag in ctags:
                    logger.debug('`{}` :contains: `{}`'.format(ctag, tag))
                    if tag.is_partial_to(ctag):
                        par = 0
        Severity: Minor
        Found in src/bratutils/agreement.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

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

            def handle_contained_tags(tag, ctags, muc):
                for ctag in ctags:
                    if ctag.is_partial_to(tag):
                        par = 0
                        if tag.comp_status != MucTable.CORRECT:
        Severity: Minor
        Found in src/bratutils/agreement.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

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

            def compare_to(self, parallel_ann):
                """Compared this object to a parallel annotation.
        
                :param parallel_ann:
                :return: True if objects are the same
        Severity: Minor
        Found in src/bratutils/agreement.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

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

            def _filter_tags(self, document):
                new_tags = []
                for tag in document.postag_list:
                    for filter_tag in self.conditions:
                        if ((self.positive_polarity and tag.tag_name == filter_tag) or
        Severity: Minor
        Found in src/bratutils/agreement.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

        Function _parse_document has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _parse_document(self, doc, no_newline):
                """
                Parse an annotation document by iterating over its lines
                """
                for line in doc:
        Severity: Minor
        Found in src/bratutils/bratdata.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

        Function update_table has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_table(self, comparison_type=None):
                """Updates the values of atributes of this object (e.g. `fsc`) that are
                calculated based on the values of the counted attributes, such as `cor`
                (correct).
        
        
        Severity: Minor
        Found in src/bratutils/agreement.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

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

            def compare_to_gold(self, parallel_doc):
                """Compares this annotation document to a parallel document.
        
                :param parallel_doc: parallel document
                :return: MucTable with degree of agreement
        Severity: Minor
        Found in src/bratutils/agreement.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 update_comp_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_comp_status(self, comp):
                """Updates the comparison status attribute using a Comparison object.
        
                :param comp: comaprison
                :type comp: Comparison
        Severity: Minor
        Found in src/bratutils/agreement.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 overlaps_with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def overlaps_with(self, parallel_ann):
                """Returns True if this annotation overlaps with the parallel
                annotation in `parallel_ann`.
        
                :param parallel_ann: parallel annotation
        Severity: Minor
        Found in src/bratutils/agreement.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

        Avoid too many return statements within this function.
        Open

                return True
        Severity: Major
        Found in src/bratutils/bratdata.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in src/bratutils/bratdata.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in src/bratutils/bratdata.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return False
              Severity: Major
              Found in src/bratutils/bratdata.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language