apel/common/datetime_utils.py

Summary

Maintainability
A
45 mins
Test Coverage

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

def iso2seconds(isoduration):
    '''
    Parses time interval encoded as ISO string.  Returns time in seconds.
    '''
    pattern = "(^P)" # P required at the beginning
Severity: Minor
Found in apel/common/datetime_utils.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

Anomalous backslash in string: '.'. String constant might be missing an r prefix.
Open

    pattern += "([0-9]+[\.,]?[0-9]*S)?"  # seconds
Severity: Minor
Found in apel/common/datetime_utils.py by pylint

Used when a backslash is in a literal string but not as an escape.

Unable to import 'iso8601'
Open

import iso8601
Severity: Critical
Found in apel/common/datetime_utils.py by pylint

Used when pylint has been unable to import a module.

At least two spaces before inline comment
Open

    pattern += "([0-9]+W)?" # weeks
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern += "([0-9]+M)?" # months
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern = "(^P)" # P required at the beginning
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern += "([0-9]+M)?" # minutes
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern += "([0-9]+Y)?" # years
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern += "([0-9]+D)?" # days
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

At least two spaces before inline comment
Open

    pattern += "([0-9]+H)?" # hours
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the
statement. They should start with a # and a single space.

Each line of a block comment starts with a # and a single space
(unless it is indented text inside the comment).

Okay: x = x + 1  # Increment x
Okay: x = x + 1    # Increment x
Okay: # Block comment
E261: x = x + 1 # Increment x
E262: x = x + 1  #Increment x
E262: x = x + 1  #  Increment x
E265: #Block comment
E266: ### Block comment

Invalid escape sequence '.'
Open

    pattern += "([0-9]+[\.,]?[0-9]*S)?"  # seconds
Severity: Minor
Found in apel/common/datetime_utils.py by pep8

Invalid escape sequences are deprecated in Python 3.6.

Okay: regex = r'\.png$'
W605: regex = '\.png$'

Variable name dt doesn't conform to snake_case naming style
Open

    dt = iso8601.parse_date(datetime_string)
Severity: Info
Found in apel/common/datetime_utils.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

standard import import re should be placed before import iso8601
Open

import re
Severity: Info
Found in apel/common/datetime_utils.py by pylint

Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

standard import import datetime should be placed before import iso8601
Open

import datetime
Severity: Info
Found in apel/common/datetime_utils.py by pylint

Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

Variable name cp doesn't conform to snake_case naming style
Open

    cp = re.compile(pattern)
Severity: Info
Found in apel/common/datetime_utils.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

There are no issues that match your filters.

Category
Status