Showing 4 of 16 total issues

Function prefill has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def prefill(self, survey, token, page=None, **post):
        cr, uid, context = request.cr, request.uid, request.context
        user_input_line_obj = request.registry['survey.user_input_line']
        ret = {}

Severity: Minor
Found in survey_percent_question/controllers/main.py - About 4 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 test_save_line_w_comments has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def test_save_line_w_comments(self):
        input_id = self.env["survey.user_input"].create({
            "token": "test",
            "survey_id": self.survey.id,
        }).id
Severity: Minor
Found in survey_percent_question/tests/test_percent_question.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 prepare_result has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_result(self, question, current_filters=None):
        '''
        Compute statistical data for questions by counting number of vote per
        choice on basis of filter
        '''
Severity: Minor
Found in survey_percent_question/models/survey.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 validate_percent_split has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_percent_split(self, question, post, answer_tag):
        answers = dict_keys_startswith(post, answer_tag)
        dec_values = []
        comment_label = answers.pop(answer_tag + '_comment_label', None)
        comment_value = answers.get(answer_tag + '_comment_value', None)
Severity: Minor
Found in survey_percent_question/models/survey_question.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

Severity
Category
Status
Source
Language