AeonLucid/POGOProtos

View on GitHub

Showing 18 of 31 total issues

Function walk_files has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

def walk_files(main_file, path, package, imports=None):
    if imports is None:
        imports = []

    if not desc_file and package == "POGOProtos":
Severity: Minor
Found in compile_single.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

Function format_protos has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

def format_protos(
        protos,
        path,
        namespace,
        path_lower,
Severity: Minor
Found in compile.py - About 7 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

File compile.py has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

import argparse
import glob
import re
Severity: Minor
Found in compile.py - About 6 hrs to fix

    Function merge_protos has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def merge_protos(protos):
        new_protos = dict()
        for proto_path in protos:
            proto_folder = list(protos[proto_path].values())
    
    
    Severity: Minor
    Found in compile.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 walk_directory has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def walk_directory(path):
        for dir_name in os.listdir(path):
            dir_name_path = os.path.join(path, dir_name)
            if os.path.isdir(dir_name_path):
                package = get_package(dir_name_path)
    Severity: Minor
    Found in compile_single.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 read_proto has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def read_proto(path):
        package = None
        imports = []
        content = []
        with open(path, 'r') as file:
    Severity: Minor
    Found in compile.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 write_proto has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def write_proto(path, name, proto):
        package, imports, content = proto
    
        if not os.path.exists(path):
            os.makedirs(path)
    Severity: Minor
    Found in compile.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 get_package has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_package(path):
        for file_name in os.listdir(path):
            file_name_path = os.path.join(path, file_name)
            if os.path.isfile(file_name_path) and file_name.endswith('.proto'):
                with open(file_name_path, 'r') as proto_file:
    Severity: Minor
    Found in compile_single.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 query_yes_no has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def query_yes_no(question, default="yes"):
        """Ask a yes/no question via raw_input() and return their answer.
    
        "question" is a string that is presented to the user.
        "default" is the presumed answer if the user just hits <Enter>.
    Severity: Minor
    Found in helpers/compile_helper.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

    Avoid deeply nested control flow statements.
    Open

                        if import_is_public:
                            new_imports_is_public[
                                new_imports_path.index(import_path)] = True
                    elif import_path != proto_path:
    Severity: Major
    Found in compile.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if is_header:
                              if proto_line.startswith("import"):
                                  import_from_package_re = re.search('import (public )?"(.*?)(\/)?([a-zA-Z0-9]+\.proto)";',
                                                                     proto_line)
      
      
      Severity: Major
      Found in compile_single.py - About 45 mins to fix

        Function format_protos has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def format_protos(
        Severity: Minor
        Found in compile.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not is_header:
                                  messages += proto_line
          
                                  if proto_line == "}":
                                      messages += "\n"
          Severity: Major
          Found in compile_single.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if import_path_split[1:-1]:
                                    import_path_path = path + '/' + \
                                        '/'.join(import_path_split[1:-1])
                                else:
                                    import_path_path = path
            Severity: Major
            Found in compile.py - About 45 mins to fix

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

              def read_protos(path):
                  protos = dict()
                  for folder_path, _, file_names in os.walk(path):
                      proto_folder = dict()
                      for file_name in file_names:
              Severity: Minor
              Found in compile.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

              Avoid deeply nested control flow statements.
              Open

                                  if proto_line.startswith("package"):
                                      return re.search('package (.*?);', proto_line).group(1)
                  return None
              Severity: Major
              Found in compile_single.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if proto_line.startswith("message") or proto_line.startswith("enum"):
                                        is_header = False
                
                
                Severity: Major
                Found in compile_single.py - About 45 mins to fix

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

                  def finish_compile(out_path, lang):
                      if lang == 'python':
                          pogo_protos_path = os.path.join(out_path, "POGOProtos")
                  
                          for root, dirnames, filenames in os.walk(pogo_protos_path):
                  Severity: Minor
                  Found in helpers/compile_helper.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