kacotam-si/portal-core

View on GitHub

Showing 10 of 10 total issues

Function render_to_csv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def render_to_csv(self, data, fieldnames=None, with_bom=True,
                      fail_silent=True):
        response = HttpResponse(content_type=self.content_type)
        response['Content-Disposition'] = self.get_context_disposition()
        if with_bom:
Severity: Minor
Found in portal_core/mixins.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 get_words has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_words(text, customdict=None):
    """ 与えられたテキストを形態素解析して、含まれる名詞のリストを返す """

    def _filter(s):
        """ 名詞だけにフィルタリングする """
Severity: Minor
Found in portal_core/utils/text_tools.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 get_bank_openday has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_bank_openday(target_date):
    """ 指定日から最寄りの銀行営業日を取得 """
    # 銀行法施行令により、12/31〜1/3が年末年始の銀行休日となる
    if datetime.date(target_date.year, 12, 31) <= target_date <= datetime.date(target_date.year + 1, 1, 3):
        # 前営業日
Severity: Minor
Found in portal_core/utils/bank.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

Line too long (107 > 79 characters)
Open

    if datetime.date(target_date.year, 12, 31) <= target_date <= datetime.date(target_date.year + 1, 1, 3):
Severity: Minor
Found in portal_core/utils/bank.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

    while date_later.isoweekday() in (6, 7) or jpholiday.is_holiday(date_later):
Severity: Minor
Found in portal_core/utils/bank.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.

Do not use bare 'except'
Open

    except:
Severity: Minor
Found in portal_core/utils/text_tools.py by pep8

When catching exceptions, mention specific exceptions when possible.

Okay: except Exception:
Okay: except BaseException:
E722: except:

Multiple spaces before operator
Open

        date_later  = datetime.date(target_date.year + 1, 1, 4)
Severity: Minor
Found in portal_core/utils/bank.py by pep8

Avoid extraneous whitespace around an operator.

Okay: a = 12 + 3
E221: a = 4  + 5
E222: a = 4 +  5
E223: a = 4\t+ 5
E224: a = 4 +\t5

Do not use bare 'except'
Open

            except:
Severity: Minor
Found in portal_core/mixins.py by pep8

When catching exceptions, mention specific exceptions when possible.

Okay: except Exception:
Okay: except BaseException:
E722: except:

Line too long (88 > 79 characters)
Open

        r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z"  # dot-atom
Severity: Minor
Found in portal_core/validators.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

    while date_earlier.isoweekday() in (6, 7) or jpholiday.is_holiday(date_earlier):
Severity: Minor
Found in portal_core/utils/bank.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.
Severity
Category
Status
Source
Language