mordred-descriptor/mordred

View on GitHub
mordred/_base/calculator.py

Summary

Maintainability
D
2 days
Test Coverage

File calculator.py has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import print_function

import sys
import warnings
from types import ModuleType
Severity: Minor
Found in mordred/_base/calculator.py - About 4 hrs to fix

    Function get_descriptors_in_module has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_descriptors_in_module(mdl, submodule=True):
        r"""Get descriptors in module.
    
        Parameters:
            mdl(module): module to search
    Severity: Minor
    Found in mordred/_base/calculator.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

    Calculator has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Calculator(object):
        r"""descriptor calculator.
    
        Parameters:
            descs: see Calculator.register() method
    Severity: Minor
    Found in mordred/_base/calculator.py - About 2 hrs to fix

      Function _calculate_one has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _calculate_one(self, cxt, desc, reset):
              if desc in self._cache:
                  return self._cache[desc]
      
              if reset:
      Severity: Minor
      Found in mordred/_base/calculator.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 _register has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _register(self, desc, version, ignore_3D):
              if not hasattr(desc, "__iter__"):
                  if is_descriptor_class(desc):
                      if desc.since > version:
                          return
      Severity: Minor
      Found in mordred/_base/calculator.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 _register_one has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _register_one(self, desc, check_only=False, ignore_3D=False):
              if not isinstance(desc, Descriptor):
                  raise ValueError("{!r} is not descriptor".format(desc))
      
              if ignore_3D and desc.require_3D:
      Severity: Minor
      Found in mordred/_base/calculator.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 pandas has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def pandas(self, mols, nproc=None, nmols=None, quiet=False, ipynb=False, id=-1):
      Severity: Minor
      Found in mordred/_base/calculator.py - About 45 mins to fix

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

            def map(self, mols, nproc=None, nmols=None, quiet=False, ipynb=False, id=-1):
        Severity: Minor
        Found in mordred/_base/calculator.py - About 45 mins to fix

          Function _serial has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _serial(self, mols, nmols, quiet, ipynb, id):
          Severity: Minor
          Found in mordred/_base/calculator.py - About 35 mins to fix

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

                def _serial(self, mols, nmols, quiet, ipynb, id):
                    with self._progress(quiet, nmols, ipynb) as bar:
                        for m in mols:
                            with Capture() as capture:
                                r = self._wrap_result(
            Severity: Minor
            Found in mordred/_base/calculator.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 get_descriptors_from_module has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_descriptors_from_module(mdl, submodule=False):
                r"""[DEPRECATED] Get descriptors from module.
            
                Parameters:
                    mdl(module): module to search
            Severity: Minor
            Found in mordred/_base/calculator.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                all_functions = (getattr(mdl, name) for name in __all__ if name[:1] != "_")
            Severity: Minor
            Found in mordred/_base/calculator.py and 1 other location - About 30 mins to fix
            mordred/_base/calculator.py on lines 453..453

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                all_values = (getattr(mdl, name) for name in __all__ if name[:1] != "_")
            Severity: Minor
            Found in mordred/_base/calculator.py and 1 other location - About 30 mins to fix
            mordred/_base/calculator.py on lines 419..419

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status