Lambda-School-Labs/Labs26-StorySquad-DS-TeamB

View on GitHub

Showing 8 of 8 total issues

Function cluster has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def cluster(cohort_submissions: dict) -> list:
    """
    Splits given dict into clusters of 4 based on their ranked complexity

    The 'remainder problem' of needing to have 4 submissions per cluster,
Severity: Minor
Found in project/app/utils/clustering/clustering_mvp.py - About 3 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 image_confidence has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def image_confidence(image_path):
    """
    Detects text in images and calculates the confidence level for each
    character. Returns a True boolean if the overall confidence for the
    page is less than 0.85. Otherwise, returns False
Severity: Minor
Found in project/app/utils/img_processing/confidence_flag.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 metrics has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def metrics(document: str):
    """
    Cleans and generates metrics for a single story transcription.

    Called within squad_score async function, so only need be run separately
Severity: Minor
Found in project/app/utils/complexity/squad_score.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

Avoid deeply nested control flow statements.
Open

                        if self.text_moderator.check_word(str(word).lower()):
                            flagged = True
                        for symbol in word.symbols:
Severity: Major
Found in project/app/utils/img_processing/google_api.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            for symbol in word.symbols:
                                symbol_confidences.append(symbol.confidence)
            # Calculate the overall confidence for the page
            page_confidence = sum(symbol_confidences) / len(symbol_confidences)
    Severity: Major
    Found in project/app/utils/img_processing/google_api.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for symbol in word.symbols:
                              symbol_confidences.append(symbol.confidence)
      
          # If there is no text on the page
          if len(symbol_confidences) == 0:
      Severity: Major
      Found in project/app/utils/img_processing/confidence_flag.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

                        return JSONResponse(
        Severity: Major
        Found in project/app/utils/security/header_checking.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return custom_route_handler
          Severity: Major
          Found in project/app/utils/security/header_checking.py - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language