tools/closure_linter/closure_linter/indentation.py

Summary

Maintainability
F
3 days
Test Coverage

Function CheckToken has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

  def CheckToken(self, token, state):
    """Checks a token for indentation errors.

    Args:
      token: The current token under consideration
Severity: Minor
Found in tools/closure_linter/closure_linter/indentation.py - About 1 day 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

File indentation.py has 367 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
#
# Copyright 2010 The Closure Linter Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Severity: Minor
Found in tools/closure_linter/closure_linter/indentation.py - About 4 hrs to fix

    Function _GetAllowableIndentations has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      def _GetAllowableIndentations(self):
        """Computes the set of allowable indentations.
    
        Returns:
          The set of allowable indentations, given the current stack.
    Severity: Minor
    Found in tools/closure_linter/closure_linter/indentation.py - About 4 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 _Add has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def _Add(self, token_info):
        """Adds the given token info to the stack.
    
        Args:
          token_info: The token information to add.
    Severity: Minor
    Found in tools/closure_linter/closure_linter/indentation.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 _Pop has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def _Pop(self):
        """Pops the top token from the stack.
    
        Returns:
          The popped token info.
    Severity: Minor
    Found in tools/closure_linter/closure_linter/indentation.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

    Avoid deeply nested control flow statements.
    Open

                if (token.line_number == stack[-1].token.line_number):
                  self._Add(TokenInfo(token))
              elif token.metadata.context.type == Context.CASE_BLOCK:
    Severity: Major
    Found in tools/closure_linter/closure_linter/indentation.py - About 45 mins to fix

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

        def _IsLastCodeInLine(self, token):
          """Determines if the given token is the last code token on its line.
      
          Args:
            token: The token.
      Severity: Minor
      Found in tools/closure_linter/closure_linter/indentation.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 _GetActualIndentation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def _GetActualIndentation(self, token):
          """Gets the actual indentation of the line containing the given token.
      
          Args:
            token: Any token on the line.
      Severity: Minor
      Found in tools/closure_linter/closure_linter/indentation.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