uclouvain/osis-common

View on GitHub

Showing 60 of 60 total issues

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

class FloatFormatInput(Input):
    input_type = 'text'
    template_name = 'django/forms/widgets/number.html'

    def __init__(self, attrs=None, render_value=False):
Severity: Major
Found in forms/widgets.py and 1 other location - About 7 hrs to fix
forms/widgets.py on lines 33..46

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 114.

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

class DecimalFormatInput(Input):
    input_type = 'text'
    template_name = 'django/forms/widgets/number.html'

    def __init__(self, attrs=None, render_value=False):
Severity: Major
Found in forms/widgets.py and 1 other location - About 7 hrs to fix
forms/widgets.py on lines 49..62

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 114.

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 queue_listener.py has 407 lines of code (exceeds 250 allowed). Consider refactoring.
Open

##############################################################################
#
#    OSIS stands for Open Student Information System. It's an application
#    designed to manage the core business of higher education institutions,
#    such as universities, faculties, institutes and professional schools.
Severity: Minor
Found in queue/queue_listener.py - About 5 hrs to fix

    Function patterns_from_tree has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def patterns_from_tree(self, start_dir: Path) -> List:
            """
            Create urlpatterns from a directory structure.
            By default, a package is considered a namespace, and a module with one view a pattern,
            if a module has multiple views, it will also be considered a namespace.
    Severity: Minor
    Found in utils/file_router.py - About 5 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 serialize has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def serialize(obj, to_delete, last_syncs=None):
        if obj:
            fields = {}
            for f in obj.__class__._meta.fields:
                if f.is_relation and to_delete:
    Severity: Minor
    Found in models/serializable_model.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

    File xls_build.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    ##############################################################################
    #
    #    OSIS stands for Open Student Information System. It's an application
    #    designed to manage the core business of higher education institutions,
    #    such as universities, faculties, institutes and professional schools.
    Severity: Minor
    Found in document/xls_build.py - About 4 hrs to fix

      ExampleConsumer has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ExampleConsumer:
          """
          This is an example consumer that will handle unexpected interactions
          with RabbitMQ such as channel and connection closures.
      
      
      Severity: Minor
      Found in queue/queue_listener.py - About 3 hrs to fix

        Function persist has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def persist(structure):
            try:
                model_class = apps.get_model(structure.get('model'))
            except LookupError:
                return
        Severity: Minor
        Found in models/serializable_model.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 execute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def execute(sql_command):
            results = []
            if sql_command:
                if sql_command_contains_forbidden_keyword(sql_command):
                    raise PermissionDenied("SQL command contains forbidden SQL keyword")
        Severity: Minor
        Found in utils/native.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

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

        CONTENT_TYPE_CHOICES = (('application/csv', 'application/csv'),
                                ('application/doc', 'application/doc'),
                                ('application/pdf', 'application/pdf'),
                                ('application/xls', 'application/xls'),
                                ('application/xlsx', 'application/xlsx'),
        Severity: Major
        Found in models/document_file.py and 1 other location - About 2 hrs to fix
        migrations/0002_documentfile.py on lines 23..23

        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 51.

        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

                        ('content_type', models.CharField(choices=[('application/csv', 'application/csv'), ('application/doc', 'application/doc'), ('application/pdf', 'application/pdf'), ('application/xls', 'application/xls'), ('application/xlsx', 'application/xlsx'), ('application/xml', 'application/xml'), ('application/zip', 'application/zip'), ('image/jpeg', 'image/jpeg'), ('image/gif', 'image/gif'), ('image/png', 'image/png'), ('text/html', 'text/html'), ('text/plain', 'text/plain')], default='application/csv', max_length=50)),
        Severity: Major
        Found in migrations/0002_documentfile.py and 1 other location - About 2 hrs to fix
        models/document_file.py on lines 37..48

        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 51.

        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 _adjust_column_width has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def _adjust_column_width(worksheet):
            for col in worksheet.columns:
                max_length = 0
                column = col[0].column_letter  # Get the column name
                for cell in col:
        Severity: Minor
        Found in document/xls_build.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 _patterns_from_views has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _patterns_from_views(module, stem) -> List:
                """
                Gather patterns from a module's views.
                Views must implement `django.views.generic.View` (your mixins must not!) and
                be referenced in the `__all__` variable of a module to be picked.
        Severity: Minor
        Found in utils/file_router.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 listen_queue_synchronously has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def listen_queue_synchronously(queue_name, callback, counter=3):
        
            def on_message(channel, method_frame, header_frame, body):
                try:
                    callback(body)
        Severity: Minor
        Found in queue/queue_listener.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

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

            connection = pika.BlockingConnection(pika.ConnectionParameters(settings.QUEUES.get('QUEUE_URL'),
                                                                           settings.QUEUES.get('QUEUE_PORT'),
                                                                           settings.QUEUES.get('QUEUE_CONTEXT_ROOT'),
                                                                           credentials,
        Severity: Major
        Found in queue/queue_listener.py and 1 other location - About 1 hr to fix
        queue/queue_sender.py on lines 41..44

        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 44.

        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

        Severity: Major
        Found in migrations/0011_rename_username_to_update_by.py and 1 other location - About 1 hr to fix
        migrations/0017_auto_20190506_1609.py on lines 0..15

        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 44.

        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

            return pika.BlockingConnection(pika.ConnectionParameters(settings.QUEUES.get('QUEUE_URL'),
                                                                     settings.QUEUES.get('QUEUE_PORT'),
                                                                     settings.QUEUES.get('QUEUE_CONTEXT_ROOT'),
                                                                     credentials,
        Severity: Major
        Found in queue/queue_sender.py and 1 other location - About 1 hr to fix
        queue/queue_listener.py on lines 83..86

        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 44.

        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

        Severity: Major
        Found in migrations/0017_auto_20190506_1609.py and 1 other location - About 1 hr to fix
        migrations/0011_rename_username_to_update_by.py on lines 0..15

        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 44.

        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 _align_cells has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def _align_cells(ws, data):
            if data:
                for an_align in data.keys():
                    cell_reference = data.get(an_align)
                    if cell_reference:
        Severity: Minor
        Found in document/xls_build.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 _set_row_font has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def _set_row_font(key, row_numbers, ws):
            for index, row in enumerate(ws.iter_rows()):
                for r in row_numbers:
                    if index == r:
                        for cell in row:
        Severity: Minor
        Found in document/xls_build.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