adsabs/biblib-service

View on GitHub

Showing 175 of 175 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if action == 'union':
            bib_union = self.setops_libraries(
                library_id=library_uuid,
                document_data=data,
                operation='union'
Severity: Major
Found in biblib/views/operations_view.py and 1 other location - About 2 days to fix
biblib/views/operations_view.py on lines 291..318

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 236.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        elif action == 'intersection':
            bib_intersect = self.setops_libraries(
                library_id=library_uuid,
                document_data=data,
                operation='intersection'
Severity: Major
Found in biblib/views/operations_view.py and 1 other location - About 2 days to fix
biblib/views/operations_view.py on lines 259..289

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 236.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                if "error" in solr_resp.keys():
                    #If SOLR request fails, pass the error back to the user
                    current_app.logger.error("Failed to retrieve bibcodes with error: {}".format(solr_resp.get("error")))
                    valid_bibcodes = []
                    output_dict = {"error": solr_resp.get("error"), "number_added": 0, "status": status_code}
    Severity: Major
    Found in biblib/views/document_view.py and 1 other location - About 1 day to fix
    biblib/views/document_view.py on lines 529..539

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 142.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if "error" in solr_resp.keys():
                #If SOLR request fails, pass the error back to the user
                current_app.logger.error("Failed to retrieve bibcodes with error: {}".format(solr_resp.get("error")))
                valid_bibcodes = []
                output_dict = {"error": solr_resp.get("error"), "number_removed": 0, "status": status_code}
    Severity: Major
    Found in biblib/views/document_view.py and 1 other location - About 1 day to fix
    biblib/views/document_view.py on lines 479..489

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 142.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                elif data['action'] == 'remove':
                    current_app.logger.info('User requested to remove documents by query')
                    output_dict = self.remove_query_from_library(
                        library_id=library,
                        document_data=data
        Severity: Major
        Found in biblib/views/document_view.py and 1 other location - About 7 hrs to fix
        biblib/views/document_view.py on lines 624..637

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if data['action'] == 'add':
                    current_app.logger.info('User requested to add documents from query')
                    output_dict = self.add_query_to_library(
                        library_id=library,
                        document_data=data
        Severity: Major
        Found in biblib/views/document_view.py and 1 other location - About 7 hrs to fix
        biblib/views/document_view.py on lines 639..652

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def downgrade():
              # ### commands auto generated by Alembic - please adjust! ###
              op.drop_table('transaction')
              op.drop_index(op.f('ix_library_version_transaction_id'), table_name='library_version')
              op.drop_index(op.f('ix_library_version_operation_type'), table_name='library_version')
          Severity: Major
          Found in alembic/versions/4039aa74290f_sqlalchemy_versioning.py and 1 other location - About 4 hrs to fix
          alembic/versions/08c9a177f639_notes_table.py on lines 50..56

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def downgrade():
              # ### commands auto generated by Alembic - please adjust! ###
              op.drop_table('notes')
              op.drop_index(op.f('ix_notes_version_transaction_id'), table_name='notes_version')
              op.drop_index(op.f('ix_notes_version_operation_type'), table_name='notes_version')
          Severity: Major
          Found in alembic/versions/08c9a177f639_notes_table.py and 1 other location - About 4 hrs to fix
          alembic/versions/4039aa74290f_sqlalchemy_versioning.py on lines 43..49

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    try:
                        data = get_post_data(
                            request,
                            types=dict(params=dict, action=str)
                        )
            Severity: Major
            Found in biblib/views/notes_view.py and 1 other location - About 4 hrs to fix
            biblib/views/notes_view.py on lines 366..376

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 75.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    try:
                        data = get_post_data(
                            request,
                            types=dict(params=dict, action=str)
                        )
            Severity: Major
            Found in biblib/views/notes_view.py and 1 other location - About 4 hrs to fix
            biblib/views/notes_view.py on lines 277..288

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 75.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    with current_app.session_scope() as session:
                        library_names = \
                            [i.library.name for i in
                             session.query(Permissions)\
                                 .filter_by(user_id = service_uid)\
            Severity: Major
            Found in biblib/views/base_view.py and 1 other location - About 3 hrs to fix
            biblib/views/base_view.py on lines 483..488

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 73.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    with current_app.session_scope() as session:
                        library_names = \
                            [i.library.name for i in
                             session.query(Permissions)\
                                 .filter_by(user_id = service_uid)\
            Severity: Major
            Found in biblib/views/base_view.py and 1 other location - About 3 hrs to fix
            biblib/views/base_view.py on lines 349..354

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 73.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
              Severity
              Category
              Status
              Source
              Language