whylabs/whylogs-python

View on GitHub
python/whylogs/core/relations.py

Summary

Maintainability
C
1 day
Test Coverage

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

    def __call__(self, x: Any) -> bool:
        if isinstance(x, Metric):
            metric = x
            if self._op != Relation._udf:
                if not self._component:
Severity: Minor
Found in python/whylogs/core/relations.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 __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        op: Relation = Relation.no_op,
        value: Union[str, int, float, ValueGetter] = 0,
        udf: Optional[Callable[[Any], bool]] = None,
Severity: Minor
Found in python/whylogs/core/relations.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 too many return statements within this function.
Open

            return self._udf(metric or x)  # type: ignore
Severity: Major
Found in python/whylogs/core/relations.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return self._left(metric or x) and self._right(metric or x)  # type: ignore
    Severity: Major
    Found in python/whylogs/core/relations.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return x > value
      Severity: Major
      Found in python/whylogs/core/relations.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return x <= value
        Severity: Major
        Found in python/whylogs/core/relations.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return self._left(metric or x) or self._right(metric or x)  # type: ignore
          Severity: Major
          Found in python/whylogs/core/relations.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return x != value
            Severity: Major
            Found in python/whylogs/core/relations.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return not self._right(metric or x)  # type: ignore
              Severity: Major
              Found in python/whylogs/core/relations.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return x >= value
                Severity: Major
                Found in python/whylogs/core/relations.py - About 30 mins to fix

                  Line too long (97 > 79 characters)
                  Open

                              return f"{self._component or 'x'} {_TOKEN[self._op.value]} {self._value.serialize()}"
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (104 > 79 characters)
                  Open

                                      raise ValueError(f"{self._component} is not available in {metric.namespace} metric")
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (83 > 79 characters)
                  Open

                      def fullmatch(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (90 > 79 characters)
                  Open

                          return Predicate(Relation._and, left=self, right=right, component=self._component)
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (86 > 79 characters)
                  Open

                      def greater_than(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (89 > 79 characters)
                  Open

                          return Predicate(Relation._or, left=self, right=right, component=self._component)
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (97 > 79 characters)
                  Open

                              return f"{_TOKEN[self._op.value]} {self._component or 'x'} {self._value.serialize()}"
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (119 > 79 characters)
                  Open

                      return '"' + input[1:-1].replace(r"\"", '"').replace("\\\\", "\\") + '"' if input[0] == input[-1] == '"' else input
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (85 > 79 characters)
                  Open

                  _TOKEN = ["", "~", "~=", "==", "<", "<=", ">", ">=", "!=", "and", "or", "not", "udf"]
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (88 > 79 characters)
                  Open

                                      raise ValueError("Metric constraints require a specified component")
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (87 > 79 characters)
                  Open

                              return self._left(metric or x) and self._right(metric or x)  # type: ignore
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (82 > 79 characters)
                  Open

                              return Predicate(Relation._not, right=pred, component=self._component)
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (83 > 79 characters)
                  Open

                      def less_than(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (80 > 79 characters)
                  Open

                      def equals(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (83 > 79 characters)
                  Open

                      def not_equal(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (86 > 79 characters)
                  Open

                              return self._left(metric or x) or self._right(metric or x)  # type: ignore
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (84 > 79 characters)
                  Open

                                  raise ValueError("negation operator requires a predicate to negate")
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (109 > 79 characters)
                  Open

                          return f"{_TOKEN[self._op.value]} {self._left.serialize()} {self._right.serialize()}"  # type: ignore
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (81 > 79 characters)
                  Open

                      def matches(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (83 > 79 characters)
                  Open

                          return f"({str(self._left)}) {_TOKEN[self._op.value]} ({str(self._right)})"
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (87 > 79 characters)
                  Open

                                  raise ValueError("match requires a string regular expression argument")
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (88 > 79 characters)
                  Open

                      def less_or_equals(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (98 > 79 characters)
                  Open

                      def _maybe_not(self, op: Relation, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  Line too long (91 > 79 characters)
                  Open

                      def greater_or_equals(self, value: Union[str, int, float, ValueGetter]) -> "Predicate":
                  Severity: Minor
                  Found in python/whylogs/core/relations.py by pep8

                  Limit all lines to a maximum of 79 characters.

                  There are still many devices around that are limited to 80 character
                  lines; plus, limiting windows to 80 characters makes it possible to
                  have several windows side-by-side.  The default wrapping on such
                  devices looks ugly.  Therefore, please limit all lines to a maximum
                  of 79 characters. For flowing long blocks of text (docstrings or
                  comments), limiting the length to 72 characters is recommended.
                  
                  Reports error E501.

                  There are no issues that match your filters.

                  Category
                  Status