Ogwang/StackOverflowLite

View on GitHub

Showing 9 of 35 total issues

Function update has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def update(self):
        response, answer_author, question_author = {'result': False}, 0, 0
        try:
            if len(self.answer_author()) > 0:
                answer_author = self.answer_author()[0].get('user_id')
Severity: Minor
Found in app/answers/models.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

File models.py has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
    Question Model
"""
import psycopg2
import psycopg2.extensions
Severity: Minor
Found in app/questions/models.py - About 2 hrs to fix

    Function post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def post(self):
            data = request.get_json(force=True)
            data['user_id'] = session.get('user_id')
            errors = validate_login_details(data)
            if len(errors) > 0:
    Severity: Minor
    Found in app/api/v1/auth/routes.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 jwt_required has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def jwt_required(f):
        """ Ensure jwt token is provided and valid
            :param f: function to decorated
            :return: decorated function
        """
    Severity: Minor
    Found in app/utils.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

    Function migrate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def migrate(self):
            con = psycopg2.connect(**self.config)
            con.autocommit = True
            cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("select * from pg_database where datname = %(database_name)s", {'database_name': self.database})
    Severity: Minor
    Found in app/migrations/db.py - About 35 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 make_response(jsonify(response_object)), 404
    Severity: Major
    Found in app/api/v1/auth/routes.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return make_response(jsonify(response_object)), 500
      Severity: Major
      Found in app/api/v1/auth/routes.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return make_response(jsonify(response_object)), 400
        Severity: Major
        Found in app/api/v1/questions/routes.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return make_response(jsonify(response_object)), 200
          Severity: Major
          Found in app/api/v1/questions/routes.py - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language