thatandromeda/hamlet

View on GitHub

Showing 17 of 40 total issues

File train_neural_net.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from glob import glob
import json
import logging
import os
import random
Severity: Major
Found in hamlet/neural/train_neural_net.py - About 1 day to fix

    Function handle has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            start_time = now()
    
            maxfiles = options['maxfiles']
            pattern = re.compile('1721.1\-(\d+)\.txt')
    Severity: Minor
    Found in hamlet/citations/management/commands/populate_citations.py - About 2 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 handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            orig_count = Citation.objects.count()
            deleted = 0
            loopcount = 0
            for c in Citation.objects.all()[0:orig_count]:
    Severity: Minor
    Found in hamlet/citations/management/commands/delete_garbage_citations.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 train_model has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def train_model(self, filename, queryset=Thesis.objects.all()):
            # Don't bother with theses when we know we can't get text from them.
            queryset = queryset.filter(unextractable=False)
            print('About to extract all text')
            for thesis in queryset:
    Severity: Minor
    Found in hamlet/neural/train_neural_net.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 rewrite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def rewrite(max=0):
        count = 0
        fetcher = DocFetcher()
    
        items = fetcher.get_record_list(DSPACE_OAI_URI)
    Severity: Minor
    Found in hamlet/neural/rewrite_authors.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 add_people has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_people(self, people, author=True):
            """Given a list of person name strings, add Person relations."""
            if author:
                role = Contribution.AUTHOR
            else:
    Severity: Minor
    Found in hamlet/theses/models.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 extract_degree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_degree(self, metadata, item_sets):
            if item_sets:
                degree = self.extract_degree_from_sets(item_sets)
                if degree:
                    return degree
    Severity: Minor
    Found in hamlet/neural/train_neural_net.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 inner_train_model has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def inner_train_model(self, window, size, iterator, filename,
    Severity: Minor
    Found in hamlet/neural/train_neural_net.py - About 35 mins to fix

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

          def get_network_files(self, args, start_date=None, end_date=None):
              print('Network files!!!!!!')
              items = self.get_record_list(DSPACE_OAI_URI, start_date, end_date)
              parsed_items = self.parse_record_list(items)
              total_items_processed = 0
      Severity: Minor
      Found in hamlet/neural/train_neural_net.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 extract_degree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_degree(self, degree_statement):
              """Takes METS format metadata and finds degrees."""
              result = []
              try:
                  degree = re.findall(r'[A-Z][a-z]{,4}\.? ?[A-Z][a-z]{,3}\.?[A-Z]?\.?'
      Severity: Minor
      Found in hamlet/theses/models.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 _reprocess_bad has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _reprocess_bad(good, bad):
          for handle in bad.keys():
              filteredbad = [refdict for refdict in bad[handle]
                             if refdict and len(refdict['raw_ref'][0]) < 200]
      
      
      Severity: Minor
      Found in hamlet/citations/extract_refs.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 handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
              for c in Citation.objects.all():
                  if re.match(r'\d+\.', c.raw_ref):
                      c.raw_ref = re.sub(r'^\d+\. ', '', c.raw_ref).lstrip()
                      c.save()
      Severity: Minor
      Found in hamlet/citations/management/commands/remove_reference_numbering.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
      Severity: Major
      Found in hamlet/neural/train_neural_net.py - About 30 mins to fix

        Function encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def encoding(self):
                if not self._encoding:
                    detector = UniversalDetector()
                    for line in self.doc:
                        detector.feed(line)
        Severity: Minor
        Found in hamlet/common/document.py - About 25 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 extract_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def extract_date(self, metadata):
                # There will be several (representing copyright, accessioning, etc.)
                # The copyright date will be a four-digit year. Find the earliest
                # year (there may be a substantial difference between copyright year
                # and archival processing years).
        Severity: Minor
        Found in hamlet/neural/train_neural_net.py - About 25 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 extract_contributors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def extract_contributors(self, metadata):
                # Includes advisor and department.
                contributors = metadata.findall('.//dc:contributor', METS_NAMESPACE)
                advisors = []
                departments = []
        Severity: Minor
        Found in hamlet/neural/train_neural_net.py - About 25 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 _find_candidate_refs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def _find_candidate_refs(reftuples):
            # Given citation data associated with various filenames, classify the
            # citations as good or bad.
            #
            # :param reftuples: list of tuples of (filename, list of dictd of citation
        Severity: Minor
        Found in hamlet/citations/extract_refs.py - About 25 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

        Severity
        Category
        Status
        Source
        Language