apinf/apibot.ai

View on GitHub

Showing 23 of 23 total issues

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

    def post(self, request, format=None):
        # Some docs:
        # Slack
        # Basic formatting: https://api.slack.com/docs/message-formatting
        generic_error_msg = _('Something went wrong here... I will tell the developers and hopefully they will manage to fix this.')
Severity: Minor
Found in apinf_bot/apis/restviews.py - About 5 days 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

                        elif parameters['data'] == 'operations':
                            operations = parser.operation.keys()
                            if(operations):
                                # Define buttons for Slack
                                actions = []
Severity: Major
Found in apinf_bot/apis/restviews.py and 1 other location - About 1 day to fix
apinf_bot/apis/restviews.py on lines 236..272

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

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 parameters['data'] == 'paths':
                            paths = parser.paths.keys()
                            if(paths):
                                # Define buttons for Slack
                                actions = []
Severity: Major
Found in apinf_bot/apis/restviews.py and 1 other location - About 1 day to fix
apinf_bot/apis/restviews.py on lines 275..311

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

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

# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

# TODO
# v Output formatting of dictionaries
Severity: Minor
Found in apinf_bot/apis/restviews.py - About 5 hrs to fix

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

                                            if(match and match.group(1).lower() == parameters['object'].lower()):
                                                operation['path'] = path
                                                operation['method'] = method
                                                operations.append(operation)
                                                break
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 2 other locations - About 3 hrs to fix
    apinf_bot/apis/restviews.py on lines 465..469
    apinf_bot/apis/restviews.py on lines 474..478

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

    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 3 locations. Consider refactoring.
    Open

                                                    if(match and match.group(1).lower() == parameters['object'].lower()):
                                                        operation['path'] = path
                                                        operation['method'] = method
                                                        operations.append(operation)
                                                        break
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 2 other locations - About 3 hrs to fix
    apinf_bot/apis/restviews.py on lines 448..452
    apinf_bot/apis/restviews.py on lines 474..478

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

    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 3 locations. Consider refactoring.
    Open

                                                    if(match and match.group(1).lower() == parameters['object'].lower()):
                                                        operation['path'] = path
                                                        operation['method'] = method
                                                        operations.append(operation)
                                                        break
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 2 other locations - About 3 hrs to fix
    apinf_bot/apis/restviews.py on lines 448..452
    apinf_bot/apis/restviews.py on lines 465..469

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

    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(parameters['object'].lower() in operation):
                                    operation['path'] = path
                                    operation['method'] = method
                                    operations.append(operation)
                                    break
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 1 other location - About 2 hrs to fix
    apinf_bot/apis/restviews.py on lines 428..432

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

    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(parameters['object'].lower() in path):
                                    operation['path'] = path
                                    operation['method'] = method
                                    operations.append(operation)
                                    break
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 1 other location - About 2 hrs to fix
    apinf_bot/apis/restviews.py on lines 435..439

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

    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 update_site_backward(apps, schema_editor):
        """Revert site domain and name to default."""
        Site = apps.get_model('sites', 'Site')
        Site.objects.update_or_create(
            id=settings.SITE_ID,
    apinf_bot/contrib/sites/migrations/0003_set_site_domain_and_name.py on lines 14..21

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

    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 update_site_forward(apps, schema_editor):
        """Set site domain and name."""
        Site = apps.get_model('sites', 'Site')
        Site.objects.update_or_create(
            id=settings.SITE_ID,
    apinf_bot/contrib/sites/migrations/0003_set_site_domain_and_name.py on lines 26..33

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

    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

                                                    match = re.match(r'#/definitions/(\w+)', parser.specification['paths'][path][method]['responses'][status_code]['schema']['items']['$ref'])
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 1 other location - About 1 hr to fix
    apinf_bot/apis/restviews.py on lines 472..472

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

    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

                                                    match = re.match(r'#/definitions/(\w+)', parser.specification['paths'][path][method]['responses'][status_code]['schema']['$ref'])
    Severity: Major
    Found in apinf_bot/apis/restviews.py and 1 other location - About 1 hr to fix
    apinf_bot/apis/restviews.py on lines 463..463

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

    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

    Avoid deeply nested control flow statements.
    Open

                                if('tags' in parser.specification['paths'][path][method]):
                                    if(parameters['object'].lower() in [tag.lower() for tag in parser.specification['paths'][path][method]['tags']]):
                                        operation['path'] = path
                                        operation['method'] = method
                                        operations.append(operation)
    Severity: Major
    Found in apinf_bot/apis/restviews.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if(parameters['object'].lower() in path):
                                      operation['path'] = path
                                      operation['method'] = method
                                      operations.append(operation)
                                      break
      Severity: Major
      Found in apinf_bot/apis/restviews.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if('operationId' in parser.specification['paths'][path][method]):
                                        operation = {
                                            'type': 'operation',
                                            'value': parser.specification['paths'][path][method]['operationId'],
                                        }
        Severity: Major
        Found in apinf_bot/apis/restviews.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if(parameters['object'].lower() in operation):
                                          operation['path'] = path
                                          operation['method'] = method
                                          operations.append(operation)
                                          break
          Severity: Major
          Found in apinf_bot/apis/restviews.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if(operations):
                                            # Define buttons for Slack
                                            actions = []
            
                                            for operation in operations:
            Severity: Major
            Found in apinf_bot/apis/restviews.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if(definitions):
                                              # Define buttons for Slack
                                              actions = []
              
                                              for definition in definitions:
              Severity: Major
              Found in apinf_bot/apis/restviews.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if(paths):
                                                # Define buttons for Slack
                                                actions = []
                
                                                for path in paths:
                Severity: Major
                Found in apinf_bot/apis/restviews.py - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language