ionelmc/python-fields

View on GitHub

Showing 13 of 17 total issues

File __init__.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
How it works: the library is composed of 2 major parts:

* The `sealers`. They return a class that implements a container according the given specification (list of field names
  and default values).
Severity: Minor
Found in src/fields/__init__.py - About 4 hrs to fix

    Function class_sealer has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def class_sealer(fields, defaults,
                     base=__base__, make_init_func=make_init_func,
                     initializer=True, comparable=True, printable=True, convertible=False, pass_kwargs=False):
        """
        This sealer makes a normal container class. It's mutable and supports arguments with default values.
    Severity: Minor
    Found in src/fields/__init__.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 make_init_func has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_init_func(fields, defaults,
                       baseclass_name='FieldsBase',
                       header_name='__init__',
                       header_start='def {func_name}(self',
                       header_end='):\n',
    Severity: Minor
    Found in src/fields/__init__.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 __new__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(mcs, name="__blank__", bases=(), namespace=None, last_field=None, required=(), defaults=(),
                    sealer=_SealerWrapper(class_sealer)):
    
            if not bases:
                assert isinstance(sealer, _SealerWrapper)
    Severity: Minor
    Found in src/fields/__init__.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 regex_validation_sealer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def regex_validation_sealer(fields, defaults, RegexType=type(re.compile(""))):
        """
        Example sealer that just does regex-based validation.
        """
        required = set(fields) - set(defaults)
    Severity: Minor
    Found in src/fields/extras.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 make_init_func has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def make_init_func(fields, defaults,
    Severity: Major
    Found in src/fields/__init__.py - About 1 hr to fix

      Function class_sealer has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def class_sealer(fields, defaults,
      Severity: Major
      Found in src/fields/__init__.py - About 1 hr to fix

        Function exec_in_env has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def exec_in_env():
            env_path = join(base_path, ".tox", "bootstrap")
            if sys.platform == "win32":
                bin_path = join(env_path, "Scripts")
            else:
        Severity: Minor
        Found in ci/bootstrap.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

        Function __new__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __new__(mcs, name="__blank__", bases=(), namespace=None, last_field=None, required=(), defaults=(),
        Severity: Major
        Found in src/fields/__init__.py - About 50 mins to fix

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

              def __eq__(self, other):
                  if isinstance(other, OrderedDict):
                      if len(self) != len(other):
                          return False
                      for p, q in zip(self.items(), other.items()):
          Severity: Minor
          Found in src/fields/py2ordereddict.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 download_latest_artifacts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def download_latest_artifacts(account_project, build_id):
              """Download all the artifacts from the latest build."""
              if build_id is None:
                  url = "https://ci.appveyor.com/api/projects/{}".format(account_project)
              else:
          Severity: Minor
          Found in ci/appveyor-download.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 __getattr__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def __getattr__(cls, name):
                  if name.startswith("__") and name.endswith("__"):
                      return type.__getattribute__(cls, name)
                  if name in cls.__required:
                      raise TypeError("Field %r is already specified as required." % name)
          Severity: Minor
          Found in src/fields/__init__.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 __invert__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def __invert__(cls):
                  if cls.__concrete is None:
                      if not cls.__all_fields:
                          raise TypeError("You're trying to use an empty Fields factory !")
                      if cls.__defaults and cls.__last_field is not None:
          Severity: Minor
          Found in src/fields/__init__.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