saltstack/salt

View on GitHub
salt/states/grafana4_dashboard.py

Summary

Maintainability
F
3 wks
Test Coverage

File grafana4_dashboard.py has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Manage Grafana v4.0 Dashboards

.. versionadded:: 2017.7.0
Severity: Minor
Found in salt/states/grafana4_dashboard.py - About 6 hrs to fix

    Function present has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def present(name,
                base_dashboards_from_pillar=None,
                base_panels_from_pillar=None,
                base_rows_from_pillar=None,
                dashboard=None,
    Severity: Minor
    Found in salt/states/grafana4_dashboard.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

    Function _dashboard_diff has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def _dashboard_diff(_new_dashboard, _old_dashboard):
        '''Return a dictionary of changes between dashboards.'''
        diff = {}
    
        # Dashboard diff
    Severity: Minor
    Found in salt/states/grafana4_dashboard.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

    Cyclomatic complexity is too high in function _dashboard_diff. (26)
    Open

    def _dashboard_diff(_new_dashboard, _old_dashboard):
        '''Return a dictionary of changes between dashboards.'''
        diff = {}
    
        # Dashboard diff
    Severity: Minor
    Found in salt/states/grafana4_dashboard.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _cleaned has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _cleaned(_dashboard):
        '''Return a copy without fields that can differ.'''
        dashboard = copy.deepcopy(_dashboard)
    
        for ignored_dashboard_field in _IGNORED_DASHBOARD_FIELDS:
    Severity: Minor
    Found in salt/states/grafana4_dashboard.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 _auto_adjust_panel_spans has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _auto_adjust_panel_spans(dashboard):
        '''Adjust panel spans to take up the available width.
    
        For each group of panels that would be laid out on the same level, scale up
        the unspecified panel spans to fill up the level.
    Severity: Minor
    Found in salt/states/grafana4_dashboard.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

    Cyclomatic complexity is too high in function present. (21)
    Open

    def present(name,
                base_dashboards_from_pillar=None,
                base_panels_from_pillar=None,
                base_rows_from_pillar=None,
                dashboard=None,
    Severity: Minor
    Found in salt/states/grafana4_dashboard.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _inherited_panel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _inherited_panel(panel, base_panels_from_pillar, ret):
        '''Return a panel with properties from parents.'''
        base_panels = []
        for base_panel_from_pillar in base_panels_from_pillar:
            base_panel = __salt__['pillar.get'](base_panel_from_pillar)
    Severity: Minor
    Found in salt/states/grafana4_dashboard.py - About 45 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 _inherited_dashboard has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _inherited_dashboard(dashboard, base_dashboards_from_pillar, ret):
        '''Return a dashboard with properties from parents.'''
        base_dashboards = []
        for base_dashboard_from_pillar in base_dashboards_from_pillar:
            base_dashboard = __salt__['pillar.get'](base_dashboard_from_pillar)
    Severity: Minor
    Found in salt/states/grafana4_dashboard.py - About 45 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 _inherited_row has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _inherited_row(row, base_rows_from_pillar, ret):
        '''Return a row with properties from parents.'''
        base_rows = []
        for base_row_from_pillar in base_rows_from_pillar:
            base_row = __salt__['pillar.get'](base_row_from_pillar)
    Severity: Minor
    Found in salt/states/grafana4_dashboard.py - About 45 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

    Avoid too many return statements within this function.
    Open

        return ret
    Severity: Major
    Found in salt/states/grafana4_dashboard.py - About 30 mins to fix

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

      def _dashboard_diff(_new_dashboard, _old_dashboard):
          '''Return a dictionary of changes between dashboards.'''
          diff = {}
      
          # Dashboard diff
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 wk to fix
      salt/states/grafana_dashboard.py on lines 469..537

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

      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

      def _auto_adjust_panel_spans(dashboard):
          '''Adjust panel spans to take up the available width.
      
          For each group of panels that would be laid out on the same level, scale up
          the unspecified panel spans to fill up the level.
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 2 days to fix
      salt/states/grafana_dashboard.py on lines 331..362

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

      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

      def _inherited_dashboard(dashboard, base_dashboards_from_pillar, ret):
          '''Return a dashboard with properties from parents.'''
          base_dashboards = []
          for base_dashboard_from_pillar in base_dashboards_from_pillar:
              base_dashboard = __salt__['pillar.get'](base_dashboard_from_pillar)
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 day to fix
      salt/states/grafana_dashboard.py on lines 261..282

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

      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

      def _cleaned(_dashboard):
          '''Return a copy without fields that can differ.'''
          dashboard = copy.deepcopy(_dashboard)
      
          for ignored_dashboard_field in _IGNORED_DASHBOARD_FIELDS:
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 day to fix
      salt/states/grafana_dashboard.py on lines 241..258

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

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

      def _inherited_row(row, base_rows_from_pillar, ret):
          '''Return a row with properties from parents.'''
          base_rows = []
          for base_row_from_pillar in base_rows_from_pillar:
              base_row = __salt__['pillar.get'](base_row_from_pillar)
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 3 other locations - About 1 day to fix
      salt/states/grafana4_dashboard.py on lines 330..348
      salt/states/grafana_dashboard.py on lines 285..303
      salt/states/grafana_dashboard.py on lines 306..324

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

      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

      def _ensure_pinned_rows(dashboard):
          '''Pin rows to the top of the dashboard.'''
          pinned_row_titles = __salt__['pillar.get'](_PINNED_ROWS_PILLAR)
          if not pinned_row_titles:
              return
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 day to fix
      salt/states/grafana_dashboard.py on lines 365..380

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

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

      def _inherited_panel(panel, base_panels_from_pillar, ret):
          '''Return a panel with properties from parents.'''
          base_panels = []
          for base_panel_from_pillar in base_panels_from_pillar:
              base_panel = __salt__['pillar.get'](base_panel_from_pillar)
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 3 other locations - About 1 day to fix
      salt/states/grafana4_dashboard.py on lines 309..327
      salt/states/grafana_dashboard.py on lines 285..303
      salt/states/grafana_dashboard.py on lines 306..324

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

      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

      def _ensure_annotations(dashboard):
          '''Explode annotation_tags into annotations.'''
          if 'annotation_tags' not in dashboard:
              return
          tags = dashboard['annotation_tags']
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 6 hrs to fix
      salt/states/grafana_dashboard.py on lines 392..413

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

      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

              if response.get('status') == 'success':
                  ret['comment'] = 'Dashboard {0} created.'.format(name)
                  ret['changes']['new'] = 'Dashboard {0} created.'.format(name)
              else:
                  ret['result'] = False
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 5 hrs to fix
      salt/states/grafana_dashboard.py on lines 132..138

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

      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

              if __opts__['test']:
                  ret['result'] = None
                  ret['comment'] = (
                      str('Dashboard {0} is set to be updated, changes={1}').format(  # future lint: blacklisted-function
                          name,
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 3 hrs to fix
      salt/states/grafana_dashboard.py on lines 159..173

      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

      def _ensure_panel_ids(dashboard):
          '''Assign panels auto-incrementing IDs.'''
          panel_id = 1
          for row in dashboard.get('rows', []):
              for panel in row.get('panels', []):
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 2 hrs to fix
      salt/states/grafana_dashboard.py on lines 383..389

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

      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

          for row in rows:
              panels = row.get('panels', [])
              for i, panel in enumerate(panels):
                  panels[i] = _inherited_panel(panel, base_panels_from_pillar, ret)
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 hr to fix
      salt/states/grafana_dashboard.py on lines 114..117

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

      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

      def _stripped(d):
          '''Strip falsey entries.'''
          ret = {}
          for k, v in six.iteritems(d):
              if v:
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 hr to fix
      salt/states/grafana_dashboard.py on lines 540..546

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

      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

          for old_row in old_dashboard.get('rows', []):
              if old_row.get('title') not in managed_row_titles:
                  new_rows.append(copy.deepcopy(old_row))
      Severity: Major
      Found in salt/states/grafana4_dashboard.py and 1 other location - About 1 hr to fix
      salt/states/grafana_dashboard.py on lines 146..148

      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

      There are no issues that match your filters.

      Category
      Status