whylabs/whylogs-python

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

Summary

Maintainability
C
7 hrs
Test Coverage

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

def _deserialize(
    token: List[str], i: int, metric: Optional[Metric] = None, profile: Optional[DatasetProfile] = None
) -> Tuple[Predicate, int]:
    if token[i] == "~":
        component, i = _get_component(token, i + 1)
Severity: Minor
Found in python/whylogs/core/predicate_parser.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 _get_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _get_value(
    token: List[str], i: int, metric: Optional[Metric] = None, profile: Optional[DatasetProfile] = None
) -> Tuple[ValueGetter, int]:
    if token[i].startswith('"'):
        return LiteralGetter(token[i][1:-1]), i + 1
Severity: Minor
Found in python/whylogs/core/predicate_parser.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

Avoid too many return statements within this function.
Open

    return LiteralGetter(float(token[i])), i + 1
Severity: Major
Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return Predicate(Relation._or, left=left, right=right, component=left._component), i
    Severity: Major
    Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return Predicate(Relation.geq, value, component=component), i
      Severity: Major
      Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return Predicate(Relation.greater, value, component=component), i
        Severity: Major
        Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return Predicate(Relation.neq, value, component=component), i
          Severity: Major
          Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return Predicate(Relation.leq, value, component=component), i
            Severity: Major
            Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return Predicate(Relation._and, left=left, right=right, component=left._component), i
              Severity: Major
              Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return Predicate(Relation._not, right=right, component=right._component), i
                Severity: Major
                Found in python/whylogs/core/predicate_parser.py - About 30 mins to fix

                  Line too long (92 > 79 characters)
                  Open

                          return Predicate(Relation._or, left=left, right=right, component=left._component), i

                  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 (107 > 79 characters)
                  Open

                      return token[i], i + 1  # either dummy variable x or metric component name in metric::to_summary_dict()

                  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 (116 > 79 characters)
                  Open

                  _TOKEN_RE = re.compile(r'(?::(?:[^:]|\\:)*:[_a-zA-Z0-9]+/[_a-zA-Z0-9:/]+)|(?:[^ ":][^ ]*)|"(?:[^\\"]|\\[^"]|\\")*"')

                  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 (94 > 79 characters)
                  Open

                  # pull out the column name and path. They have an optional submetric_name:submetric_namespace/

                  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 (94 > 79 characters)
                  Open

                      expression: str, metric: Optional[Metric] = None, profile: Optional[DatasetProfile] = None

                  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(f"Expected {namespace} metric but got {metric.namespace}")

                  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 (103 > 79 characters)
                  Open

                      token: List[str], i: int, metric: Optional[Metric] = None, profile: Optional[DatasetProfile] = None

                  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 (99 > 79 characters)
                  Open

                  _PROFILE_REF = re.compile(r":(.+?):([_a-zA-Z0-9]+/(?:[_a-zA-Z0-9]+:[_a-zA-Z0-9]+/)?[_a-zA-Z0-9]+)")

                  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

                  # These match metric references with our without column names, with capture groups to

                  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 (103 > 79 characters)
                  Open

                      token: List[str], i: int, metric: Optional[Metric] = None, profile: Optional[DatasetProfile] = None

                  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

                  _METRIC_REF = re.compile(r"::[_a-zA-Z0-9]+/(?:[_a-zA-Z0-9]+:[_a-zA-Z0-9]+/)?[_a-zA-Z0-9]+")

                  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 Predicate(Relation._not, right=right, component=right._component), i

                  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 (108 > 79 characters)
                  Open

                  # (?::(?:[^:]|\\:)*:[_a-zA-Z0-9]+/[_a-zA-Z0-9:/]+) matches metric references with \: escaped in column names

                  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

                  # "(?:[^\\"]|\\[^"]|\\")*" matches quoted strings with \"  \\ escaped quotes and \

                  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 (93 > 79 characters)
                  Open

                          return Predicate(Relation._and, left=left, right=right, component=left._component), i

                  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 (96 > 79 characters)
                  Open

                      raise ValueError("Unable to parse predicate expression '{' '.join(token)}' at token {i+1}.")

                  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