CSCfi/pebbles

View on GitHub

Showing 169 of 169 total issues

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

def toggle_enable_template(form, args, application_template):
    """Logic for activating and deactivating a application template"""
    if form.is_enabled.raw_data:
        application_template.is_enabled = form.is_enabled.raw_data[0]  # WTForms Issue#451
    else:
Severity: Minor
Found in pebbles/views/application_templates.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def check_membership_expiry_policy(mep):
        """ Return validation errors for given membership expiry policy or None if successful """
        if not isinstance(mep, dict):
            return 'membership expiry policy must be a dict'
        kind = mep.get('kind')
Severity: Minor
Found in pebbles/models.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        self.cluster_controller = ClusterController(
            worker_id=self.id,
            config=self.config,
            cluster_config=self.cluster_config,
            client=self.client,
Severity: Minor
Found in pebbles/worker/main.py and 2 other locations - About 35 mins to fix
pebbles/worker/main.py on lines 34..38
pebbles/worker/main.py on lines 48..52

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

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

def load_data(file, update=False):
    """
    Loads an annotated YAML file into database. Use -u/--update to update existing entries instead of skipping.
    """
    with open(file, 'r') as f:
Severity: Minor
Found in manage.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def __init__(self):
        for k, default in vars(BaseConfig).items():
            if type(default) is tuple and len(default) == 2:
                default, doc_ = default
            else:
Severity: Minor
Found in pebbles/config.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def __init__(self, ext_id, password=None, is_admin=False, email_id=None, expiry_ts=None, pseudonym=None,
                 workspace_quota=None):
        self.id = uuid.uuid4().hex
        self.ext_id = ext_id
        self.is_admin = is_admin
Severity: Minor
Found in pebbles/models.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def post(self):
        res = []

        for entry in request.json:
            target = entry.get('target')
Severity: Minor
Found in pebbles/views/alerts.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

def env_string_to_dict(keyval_string):
    """ Extract a dictionary from space separated key=val formatted string """
    res = dict()
    for keyval in keyval_string.split():
        if '=' not in keyval:
Severity: Minor
Found in pebbles/utils.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        self.application_session_controller = ApplicationSessionController(
            worker_id=self.id,
            config=self.config,
            cluster_config=self.cluster_config,
            client=self.client,
Severity: Minor
Found in pebbles/worker/main.py and 2 other locations - About 35 mins to fix
pebbles/worker/main.py on lines 41..45
pebbles/worker/main.py on lines 48..52

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

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

    def patch(self, workspace_id):
        parser = reqparse.RequestParser()
        parser.add_argument('new_owner_id', type=str)

        args = parser.parse_args()
Severity: Minor
Found in pebbles/views/workspaces.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        self.workspace_controller = WorkspaceController(
            worker_id=self.id,
            config=self.config,
            cluster_config=self.cluster_config,
            client=self.client,
Severity: Minor
Found in pebbles/worker/main.py and 2 other locations - About 35 mins to fix
pebbles/worker/main.py on lines 34..38
pebbles/worker/main.py on lines 41..45

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

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 too many return statements within this function.
Open

        return marshal_based_on_role(user, workspace)
Severity: Major
Found in pebbles/views/workspaces.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return val
    Severity: Major
    Found in pebbles/config.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                          return ts, 'starting'
      Severity: Major
      Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 30 mins to fix

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

                    env_var_dict = {k: v for k, v in [x.split('=') for x in env_var_array]}
        Severity: Minor
        Found in pebbles/drivers/provisioning/openshift_template_driver.py and 1 other location - About 30 mins to fix
        pebbles/drivers/provisioning/kubernetes_driver.py on lines 372..372

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

        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 too many return statements within this function.
        Open

                    return {'error': 'User %s needs owner privileges, please contact administrator' % args.new_owner_id}, 403
        Severity: Major
        Found in pebbles/views/workspaces.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return 'Invalid attribute limits, error: %s' % error, 422
          Severity: Major
          Found in pebbles/views/applications.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return application.attribute_limits
            Severity: Major
            Found in pebbles/views/applications.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return 'There is already an existing session for this application', 409
              Severity: Major
              Found in pebbles/views/application_sessions.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return ts, 'image could not be pulled'
                Severity: Major
                Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language