thatandromeda/hamlet

View on GitHub
hamlet/neural/train_neural_net.py

Summary

Maintainability
D
1 day
Test Coverage

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

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

        There are no issues that match your filters.

        Category
        Status