benjixx/goodplay

View on GitHub

Showing 74 of 74 total issues

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

    create_role(local_role_base_path, 'role2', '''---
- hosts: 127.0.0.1
  roles:
    - role: role2

Severity: Minor
Found in tests/test_ansible_role_support_integration.py and 1 other location - About 50 mins to fix
tests/test_ansible_role_support_integration.py on lines 187..208

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

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 test_is_test_playbook_file_with_valid_content(
        tmpdir, valid_test_playbook_content):
    path = tmpdir.join('test_playbook.yml')
    path.write(valid_test_playbook_content)

Severity: Minor
Found in tests/test_ansible_support.py and 1 other location - About 50 mins to fix
tests/test_ansible_support.py on lines 71..76

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

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 test_is_test_playbook_file_with_valid_prefix(
        tmpdir, valid_test_playbook):
    path = tmpdir.join('test_playbook.yml')
    path.write(valid_test_playbook)

Severity: Minor
Found in tests/test_ansible_support.py and 1 other location - About 50 mins to fix
tests/test_ansible_support.py on lines 107..112

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

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 test_failed_on_unreachable_host_on_gather_facts(testdir):
    result = create_playbook_and_run(testdir, '''---
- hosts: unreachable.host.local
  tasks:
    - name: task1
Severity: Minor
Found in tests/test_ansible_runner_integration.py and 1 other location - About 40 mins to fix
tests/test_ansible_runner_integration.py on lines 110..128

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

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 test_skipped_outcome_takes_priority_over_passed(testdir):
    result = create_playbook_and_run(testdir, '''---
- hosts: host1
  tasks:
    - name: avoid all test tasks skipped
Severity: Minor
Found in tests/test_ansible_runner_integration.py and 1 other location - About 40 mins to fix
tests/test_ansible_runner_integration.py on lines 207..216

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

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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, ctx, fspath, parent=None, config=None, session=None):
Severity: Minor
Found in goodplay/plugin.py - About 35 mins to fix

    Function create_role has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_role(
    Severity: Minor
    Found in tests/test_ansible_role_support_integration.py - About 35 mins to fix

      Function __iter__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __iter__(self):
              # override default Capture to read lines as long as streams are open,
              # thus iteration is not being stopped by large pauses between lines
              # being available
              while self.streams_open():
      Severity: Minor
      Found in goodplay/utils/subprocess.py - About 25 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 platform_manager has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def platform_manager(self):
              platform_manager = PlatformManager.from_dicts(self.config['platforms'])
      
              if self.is_platform_matrix_requested:
                  platforms = self.role_meta_info['galaxy_info'].get('platforms', [])
      Severity: Minor
      Found in goodplay/context.py - About 25 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 final_test_task_outcome has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def final_test_task_outcome(self):
              if self.per_host_outcomes:
                  outcomes = set(x['outcome'] for x in self.per_host_outcomes.values())
                  outcome_priority = ('failed', 'skipped', 'passed')
                  for outcome in outcome_priority:
      Severity: Minor
      Found in goodplay/ansible_support/callback_plugin/goodplay.py - About 25 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 wait_for_event has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def wait_for_event(self, event_name=None, **kwargs):
              for event in self.receive_events():
                  if event['event_name'] == event_name \
                          and set(kwargs.items()).issubset(set(event['data'].items())):
                      return event
      Severity: Minor
      Found in goodplay/ansible_support/runner.py - About 25 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 role_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def role_path(self):
              for ancestor_path in self.playbook_path.parts(reverse=True)[1:]:
                  if ancestor_path.basename == 'tests':
                      role_path = ancestor_path.dirpath()
                      is_role_path = role_path.join('meta', 'main.yml').check(file=True)
      Severity: Minor
      Found in goodplay/context.py - About 25 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 pull_required_images has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def pull_required_images(self):
              required_images = set()
      
              for host in self.ctx.inventory.hosts():
                  required_image = self.get_docker_image_for_host(host)
      Severity: Minor
      Found in goodplay/docker_support/__init__.py - About 25 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

      'async' and 'await' are reserved keywords starting with python 3.7
      Open

                  env=env, async=True)
      Severity: Minor
      Found in goodplay/ansible_support/runner.py by pep8

      'async' and 'await' are reserved keywords starting at Python 3.7.

      W606: async = 42
      W606: await = 42
      Okay: async def read(db):
      data = await db.fetch('SELECT ...')
      Severity
      Category
      Status
      Source
      Language