adsabs/biblib-service

View on GitHub

Showing 114 of 175 total issues

File base_view.py has 653 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Base view
"""
import uuid
import base64
Severity: Major
Found in biblib/views/base_view.py - About 1 day to fix

    File document_view.py has 559 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Document view
    """
    
    from biblib.utils import err, get_post_data, get_GET_params
    Severity: Major
    Found in biblib/views/document_view.py - About 1 day to fix

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

          def post(self, library):
              """
              HTTP POST request that conducts operations at the library level.
      
              :param library: primary library ID
      Severity: Minor
      Found in biblib/views/operations_view.py - About 1 day 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 library_view.py has 502 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Library view
      """
      
      from biblib.views import USER_ID_KEYWORD
      Severity: Major
      Found in biblib/views/library_view.py - About 1 day to fix

        File permission_view.py has 429 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Perimssion view
        """
        
        from flask import request, current_app
        Severity: Minor
        Found in biblib/views/permission_view.py - About 6 hrs to fix

          File notes_view.py has 345 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from biblib.utils import err, get_post_data
          from biblib.models import Notes
          from biblib.views.base_view import BaseView
          from flask import request, current_app
          from flask_discoverer import advertise
          Severity: Minor
          Found in biblib/views/notes_view.py - About 4 hrs to fix

            Function update_notes has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_notes(cls, session, library, updated_list):
                    """
                    Updates the notes based on the solr canonical bibcodes response
                    :param session: necessary for all the queries 
                    :param library: library to update
            Severity: Minor
            Found in biblib/views/library_view.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 operations_view.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            Operations view
            """
            from biblib.views import USER_ID_KEYWORD
            from biblib.utils import err, get_post_data
            Severity: Minor
            Found in biblib/views/operations_view.py - About 3 hrs to fix

              BaseView has 27 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class BaseView(Resource):
                  """
                  A base view class to keep a single version of common functions used between
                  all of the views.
                  """
              Severity: Minor
              Found in biblib/views/base_view.py - About 3 hrs to fix

                Function get_libraries has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_libraries(cls, service_uid, absolute_uid, start=0, rows=None, sort_col="date_created", sort_order="desc", access_type="all"):
                        """
                        Get all the libraries a user has
                        :param service_uid: microservice UID of the user
                        :param absolute_uid: unique UID of the user in the API
                Severity: Minor
                Found in biblib/views/user_view.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

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

                """
                Models use to define the database
                
                The database is not initiated here, but a pointer is created named db. This is
                to be passed to the app creator within the Flask blueprint.
                Severity: Minor
                Found in biblib/models.py - About 2 hrs to fix

                  File user_view.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                  User view
                  """
                  
                  from biblib.utils import err, get_post_data, check_boolean
                  Severity: Minor
                  Found in biblib/views/user_view.py - About 2 hrs to fix

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

                        def post(self, library):
                            """
                            HTTP POST request that adds a document to a library for a given user
                            :param library: library ID
                    
                    
                    Severity: Minor
                    Found in biblib/views/document_view.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 add_permission has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def add_permission(service_uid, library_id, permission):
                            """
                            Adds a permission for a user to a specific library
                            :param service_uid: the user ID within this microservice
                            :param library_id: the library id to update
                    Severity: Minor
                    Found in biblib/views/permission_view.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 post has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def post(self, library):
                            """
                            HTTP POST request that adds a document to a library for a given user
                            :param library: library ID
                    
                    
                    Severity: Minor
                    Found in biblib/views/document_view.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 add_document_to_library has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def add_document_to_library(cls, library_id, document_data):
                            """
                            Adds a document to a user's library
                            :param library_id: the library id to update
                            :param document_data: the meta data of the document
                    Severity: Minor
                    Found in biblib/views/document_view.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 put has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def put(self, library):
                            """
                            HTTP PUT request that updates the meta-data of the library
                            :param library: library ID
                    
                    
                    Severity: Minor
                    Found in biblib/views/document_view.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 solr_update_library has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def solr_update_library(cls, library_id, solr_docs, session):
                            """
                            Updates the library based on the solr canonical bibcodes response
                            :param library: library_id of the library to update
                            :param solr_docs: solr docs from the bigquery response
                    Severity: Minor
                    Found in biblib/views/library_view.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_post_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_post_data(request, types={}):
                        """
                        Attempt to coerce POST json data from the request, falling
                        back to the raw data if json could not be coerced.
                        :param request: flask.request
                    Severity: Minor
                    Found in biblib/utils.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 post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def post(self, library):
                            """
                            HTTP POST request that modifies the permissions of a library
                            :param library: library ID
                    
                    
                    Severity: Minor
                    Found in biblib/views/permission_view.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

                    Severity
                    Category
                    Status
                    Source
                    Language