saltstack/salt

View on GitHub
salt/modules/mysql.py

Summary

Maintainability
F
2 wks
Test Coverage

File mysql.py has 1833 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Module to provide MySQL compatibility to salt.

:depends:   - MySQLdb Python module
Severity: Major
Found in salt/modules/mysql.py - About 5 days to fix

    Function _grant_to_tokens has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def _grant_to_tokens(grant):
        '''
    
        This should correspond fairly closely to the YAML rendering of a
        mysql_grants state which comes out as follows:
    Severity: Minor
    Found in salt/modules/mysql.py - About 6 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 user_chpass has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_chpass(user,
                    host='localhost',
                    password=None,
                    password_hash=None,
                    allow_passwordless=False,
    Severity: Minor
    Found in salt/modules/mysql.py - About 4 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 file_query has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def file_query(database, file_name, **connection_args):
        '''
        Run an arbitrary SQL query from the specified file and return the
        the number of affected rows.
    
    
    Severity: Minor
    Found in salt/modules/mysql.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 grant_exists has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def grant_exists(grant,
                     database,
                     user,
                     host='localhost',
                     grant_option=False,
    Severity: Minor
    Found in salt/modules/mysql.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 user_create has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_create(user,
                    host='localhost',
                    password=None,
                    password_hash=None,
                    allow_passwordless=False,
    Severity: Minor
    Found in salt/modules/mysql.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 _connect has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _connect(**kwargs):
        '''
        wrap authentication credentials here
        '''
        connargs = dict()
    Severity: Minor
    Found in salt/modules/mysql.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 user_exists has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_exists(user,
                    host='localhost',
                    password=None,
                    password_hash=None,
                    passwordless=False,
    Severity: Minor
    Found in salt/modules/mysql.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 _grant_to_tokens. (25)
    Open

    def _grant_to_tokens(grant):
        '''
    
        This should correspond fairly closely to the YAML rendering of a
        mysql_grants state which comes out as follows:
    Severity: Minor
    Found in salt/modules/mysql.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

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

    def grant_exists(grant,
                     database,
                     user,
                     host='localhost',
                     grant_option=False,
    Severity: Minor
    Found in salt/modules/mysql.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 query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def query(database, query, **connection_args):
        '''
        Run an arbitrary SQL query and return the results or
        the number of affected rows.
    
    
    Severity: Minor
    Found in salt/modules/mysql.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 __grant_generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def __grant_generate(grant,
                        database,
                        user,
                        host='localhost',
                        grant_option=False,
    Severity: Minor
    Found in salt/modules/mysql.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 slave_lag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def slave_lag(**connection_args):
        '''
        Return the number of seconds that a slave SQL server is lagging behind the
        master, if the host is not a slave it will return -1.  If the server is
        configured to be a slave for replication but slave IO is not running then
    Severity: Minor
    Found in salt/modules/mysql.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 grant_revoke has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def grant_revoke(grant,
                     database,
                     user,
                     host='localhost',
                     grant_option=False,
    Severity: Minor
    Found in salt/modules/mysql.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

    Avoid too many return statements within this function.
    Open

        return False
    Severity: Major
    Found in salt/modules/mysql.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return True
      Severity: Major
      Found in salt/modules/mysql.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return False
        Severity: Major
        Found in salt/modules/mysql.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return cur.rowcount == 1
          Severity: Major
          Found in salt/modules/mysql.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return True
            Severity: Major
            Found in salt/modules/mysql.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return True
              Severity: Major
              Found in salt/modules/mysql.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return -2
                Severity: Major
                Found in salt/modules/mysql.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return False
                  Severity: Major
                  Found in salt/modules/mysql.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return True
                    Severity: Major
                    Found in salt/modules/mysql.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return False
                      Severity: Major
                      Found in salt/modules/mysql.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return False
                        Severity: Major
                        Found in salt/modules/mysql.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return True
                          Severity: Major
                          Found in salt/modules/mysql.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return False
                            Severity: Major
                            Found in salt/modules/mysql.py - About 30 mins to fix

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

                              def db_create(name, character_set=None, collate=None, **connection_args):
                                  '''
                                  Adds a databases to the MySQL server.
                              
                                  name
                              Severity: Minor
                              Found in salt/modules/mysql.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 user_grants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def user_grants(user,
                                              host='localhost', **connection_args):
                                  '''
                                  Shows the grants for the given MySQL user (if it exists)
                              
                              
                              Severity: Minor
                              Found in salt/modules/mysql.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 __ssl_option_sanitize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def __ssl_option_sanitize(ssl_option):
                                  new_ssl_option = []
                              
                                  # Like most other "salt dsl" YAML structures, ssl_option is a list of single-element dicts
                                  for opt in ssl_option:
                              Severity: Minor
                              Found in salt/modules/mysql.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

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

                              def get_slave_status(**connection_args):
                                  '''
                                  Retrieves the slave status from the minion.
                              
                                  Returns::
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 6 hrs to fix
                              salt/modules/mysql.py on lines 2176..2207

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

                              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 get_master_status(**connection_args):
                                  '''
                                  Retrieves the master status from the minion.
                              
                                  Returns::
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 6 hrs to fix
                              salt/modules/mysql.py on lines 2210..2277

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

                              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 showvariables(**connection_args):
                                  '''
                                  Retrieves the show variables from the minion.
                              
                                  Returns::
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 6 hrs to fix
                              salt/modules/mysql.py on lines 2308..2333

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

                              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 showglobal(**connection_args):
                                  '''
                                  Retrieves the show global variables from the minion.
                              
                                  Returns::
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 6 hrs to fix
                              salt/modules/mysql.py on lines 2280..2305

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

                              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

                              def __check_table(name, table, **connection_args):
                                  dbc = _connect(**connection_args)
                                  if dbc is None:
                                      return {}
                                  cur = dbc.cursor(MySQLdb.cursors.DictCursor)
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 279..291
                              salt/modules/mysql.py on lines 294..306

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

                              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

                              def __optimize_table(name, table, **connection_args):
                                  dbc = _connect(**connection_args)
                                  if dbc is None:
                                      return {}
                                  cur = dbc.cursor(MySQLdb.cursors.DictCursor)
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 264..276
                              salt/modules/mysql.py on lines 279..291

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

                              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

                              def __repair_table(name, table, **connection_args):
                                  dbc = _connect(**connection_args)
                                  if dbc is None:
                                      return {}
                                  cur = dbc.cursor(MySQLdb.cursors.DictCursor)
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 264..276
                              salt/modules/mysql.py on lines 294..306

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

                              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

                              def db_repair(name,
                                            table=None,
                                            **connection_args):
                                  '''
                                  Repairs the full database or just a given table
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 1659..1682
                              salt/modules/mysql.py on lines 1710..1732

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

                              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

                              def db_optimize(name,
                                            table=None,
                                            **connection_args):
                                  '''
                                  Optimizes the full database or just a given table
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 1659..1682
                              salt/modules/mysql.py on lines 1685..1707

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

                              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

                              def db_check(name,
                                           table=None,
                                           **connection_args):
                                  '''
                                  Repairs the full database or just a given table
                              Severity: Major
                              Found in salt/modules/mysql.py and 2 other locations - About 5 hrs to fix
                              salt/modules/mysql.py on lines 1685..1707
                              salt/modules/mysql.py on lines 1710..1732

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 1844..1850
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1844..1850
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 1844..1850

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 1844..1850
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1455..1461
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 1844..1850
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry, args)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 6 other locations - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1105..1111
                              salt/modules/mysql.py on lines 1317..1323
                              salt/modules/mysql.py on lines 1349..1355
                              salt/modules/mysql.py on lines 1626..1632
                              salt/modules/mysql.py on lines 1844..1850
                              salt/modules/mysql.py on lines 2058..2064

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

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

                                  try:
                                      _execute(cur, qry)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 2 hrs to fix
                              salt/modules/mysql.py on lines 1070..1076

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

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

                                  try:
                                      _execute(cur, qry)
                                  except MySQLdb.OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Major
                              Found in salt/modules/mysql.py and 1 other location - About 2 hrs to fix
                              salt/modules/mysql.py on lines 981..987

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

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

                                  if not server_version:
                                      last_err = __context__['mysql.error']
                                      err = 'MySQL Error: Unable to fetch current server version. Last error was: "{}"'.format(last_err)
                                      log.error(err)
                                      return False
                              Severity: Major
                              Found in salt/modules/mysql.py and 3 other locations - About 1 hr to fix
                              salt/modules/mysql.py on lines 1411..1415
                              salt/modules/mysql.py on lines 1521..1525
                              salt/modules/mysql.py on lines 1882..1886

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

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

                                  if not server_version:
                                      last_err = __context__['mysql.error']
                                      err = 'MySQL Error: Unable to fetch current server version. Last error was: "{}"'.format(last_err)
                                      log.error(err)
                                      return False
                              Severity: Major
                              Found in salt/modules/mysql.py and 3 other locations - About 1 hr to fix
                              salt/modules/mysql.py on lines 1267..1271
                              salt/modules/mysql.py on lines 1411..1415
                              salt/modules/mysql.py on lines 1882..1886

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

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

                                  if not server_version:
                                      last_err = __context__['mysql.error']
                                      err = 'MySQL Error: Unable to fetch current server version. Last error was: "{}"'.format(last_err)
                                      log.error(err)
                                      return False
                              Severity: Major
                              Found in salt/modules/mysql.py and 3 other locations - About 1 hr to fix
                              salt/modules/mysql.py on lines 1267..1271
                              salt/modules/mysql.py on lines 1521..1525
                              salt/modules/mysql.py on lines 1882..1886

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

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

                                  if not server_version:
                                      last_err = __context__['mysql.error']
                                      err = 'MySQL Error: Unable to fetch current server version. Last error was: "{}"'.format(last_err)
                                      log.error(err)
                                      return False
                              Severity: Major
                              Found in salt/modules/mysql.py and 3 other locations - About 1 hr to fix
                              salt/modules/mysql.py on lines 1267..1271
                              salt/modules/mysql.py on lines 1411..1415
                              salt/modules/mysql.py on lines 1521..1525

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

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

                                  try:
                                      dbc = MySQLdb.connect(**connargs)
                                  except OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Minor
                              Found in salt/modules/mysql.py and 1 other location - About 40 mins to fix
                              salt/modules/mysql.py on lines 707..713

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

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

                                  try:
                                      affected = _execute(cur, query)
                                  except OperationalError as exc:
                                      err = 'MySQL Error {0}: {1}'.format(*exc.args)
                                      __context__['mysql.error'] = err
                              Severity: Minor
                              Found in salt/modules/mysql.py and 1 other location - About 40 mins to fix
                              salt/modules/mysql.py on lines 391..397

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

                              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