netdata/netdata

View on GitHub
src/collectors/python.d.plugin/haproxy/haproxy.chart.py

Summary

Maintainability
F
4 days
Test Coverage

File haproxy.chart.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# Description: haproxy netdata python.d module
# Author: ilyam8, ktarasz
# SPDX-License-Identifier: GPL-3.0-or-later

Severity: Minor
Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py - About 3 hrs to fix

    Function _get_stat_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_stat_data(self):
            """
            :return: dict
            """
            raw_data = self.poll._get_raw_data(self)
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        def create_charts(self):
            for front in self.data['frontend']:
                name, idx = front['# pxname'], front['# pxname'].replace('.', '_')
                for metric in METRICS:
                    self.definitions['f' + metric]['lines'].append(['_'.join(['frontend', metric, idx]),
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.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 parse_data_ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_data_(data):
        def is_backend(backend):
            return backend.get('svname') == 'BACKEND' and backend.get('# pxname') != 'stats'
    
        def is_frontend(frontend):
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.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

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

                for metric in METRICS:
                    self.definitions['f' + metric]['lines'].append(['_'.join(['frontend', metric, idx]),
                                                                    name, METRICS[metric]['algorithm'], 1,
                                                                    METRICS[metric]['divisor']])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 4 hrs to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 319..322
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 325..328

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

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

                for metric in METRICS:
                    self.definitions['b' + metric]['lines'].append(['_'.join(['backend', metric, idx]),
                                                                    name, METRICS[metric]['algorithm'], 1,
                                                                    METRICS[metric]['divisor']])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 4 hrs to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 311..314
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 325..328

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

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

                for metric in BACKEND_METRICS:
                    self.definitions['b' + metric]['lines'].append(['_'.join(['backend', metric, idx]),
                                                                    name, BACKEND_METRICS[metric]['algorithm'], 1,
                                                                    BACKEND_METRICS[metric]['divisor']])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 4 hrs to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 311..314
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 319..322

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

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

                stat_data['hsup_' + idx] = len([server for server in self.data['servers']
                                                if server_status(server, name, 'UP')])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 273..274
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 275..276

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

                stat_data['hsdown_' + idx] = len([server for server in self.data['servers']
                                                  if server_status(server, name, 'DOWN')])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 271..272
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 275..276

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

                stat_data['hsmaint_' + idx] = len([server for server in self.data['servers']
                                                   if server_status(server, name, 'MAINT')])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 271..272
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 273..274

    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

                self.definitions['fhrsp_total']['lines'].append(['_'.join(['frontend', 'hrsp_total', idx]),
                                                                 name, 'incremental', 1, 1])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 1 other location - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 323..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 39.

    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

                self.definitions['bhrsp_total']['lines'].append(['_'.join(['backend', 'hrsp_total', idx]),
                                                                 name, 'incremental', 1, 1])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 1 other location - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 315..316

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

    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 is_frontend(frontend):
            return frontend.get('svname') == 'FRONTEND' and frontend.get('# pxname') != 'stats'
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 1 other location - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 336..337

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

    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 is_backend(backend):
            return backend.get('svname') == 'BACKEND' and backend.get('# pxname') != 'stats'
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 1 other location - About 1 hr to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 339..340

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

    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

                self.definitions['health_sup']['lines'].append(['hsup_' + idx, name, 'absolute'])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 3 other locations - About 35 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 330..330
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 331..331
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 332..332

    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

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

                self.definitions['health_sdown']['lines'].append(['hsdown_' + idx, name, 'absolute'])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 3 other locations - About 35 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 329..329
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 331..331
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 332..332

    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

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

                self.definitions['health_bdown']['lines'].append(['hbdown_' + idx, name, 'absolute'])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 3 other locations - About 35 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 329..329
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 330..330
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 331..331

    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

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

                self.definitions['health_smaint']['lines'].append(['hsmaint_' + idx, name, 'absolute'])
    Severity: Major
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 3 other locations - About 35 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 329..329
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 330..330
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 332..332

    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

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

                    stat_data['_'.join(['backend', metric, idx])] = backend.get(metric) or 0
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 30 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 267..267
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 278..279

    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

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

                    stat_data['_'.join(['frontend', metric, idx])] = frontend.get(metric) or 0
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 30 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 278..279
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 282..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 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

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

                for metric in BACKEND_METRICS:
                    stat_data['_'.join(['backend', metric, idx])] = backend.get(metric) or 0
    Severity: Minor
    Found in src/collectors/python.d.plugin/haproxy/haproxy.chart.py and 2 other locations - About 30 mins to fix
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 267..267
    src/collectors/python.d.plugin/haproxy/haproxy.chart.py on lines 282..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 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

    There are no issues that match your filters.

    Category
    Status