datahuborg/datahub

View on GitHub
src/core/db/backend/pg.py

Summary

Maintainability
F
2 wks
Test Coverage

File pg.py has 951 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
import os
import errno
import shutil
import hashlib
Severity: Major
Found in src/core/db/backend/pg.py - About 2 days to fix

    PGBackend has 71 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PGBackend:
    
        def __init__(self, user, password, host=HOST, port=PORT, repo_base=None):
            self.user = user
            self.password = password
    Severity: Major
    Found in src/core/db/backend/pg.py - About 1 day to fix

      Function find_security_policies has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def find_security_policies(self, repo_base, repo=None, table=None,
      Severity: Major
      Found in src/core/db/backend/pg.py - About 1 hr to fix

        Function create_security_policy has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_security_policy(self, policy, policy_type, grantee, grantor,
        Severity: Major
        Found in src/core/db/backend/pg.py - About 50 mins to fix

          Function import_file has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def import_file(self, table_name, file_path, file_format='CSV',
          Severity: Major
          Found in src/core/db/backend/pg.py - About 50 mins to fix

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

                def export_table(self, table_name, file_path, file_format='CSV',
            Severity: Minor
            Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                  def get_view_sql(self, repo_base, repo, table, view_params, license_id):
              Severity: Minor
              Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                    def export_view(self, view_name, file_path, file_format='CSV',
                Severity: Minor
                Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                      def __init__(self, user, password, host=HOST, port=PORT, repo_base=None):
                  Severity: Minor
                  Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                        def import_rows(self, repo, table, rows, delimiter=',', header=False):
                    Severity: Minor
                    Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                          def create_license_view(self, repo_base, repo,
                      Severity: Minor
                      Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                            def export_query(self, query, file_path, file_format='CSV',
                        Severity: Minor
                        Found in src/core/db/backend/pg.py - About 35 mins to fix

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

                          def _convert_pg_exception(e):
                              # Convert some psycopg2 errors into exceptions meaningful to
                              # Django.
                              if (e.pgcode == errorcodes.INSUFFICIENT_PRIVILEGE):
                                  raise PermissionDenied()
                          Severity: Minor
                          Found in src/core/db/backend/pg.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 find_security_policies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def find_security_policies(self, repo_base, repo=None, table=None,
                                                         policy_id=None, policy=None, policy_type=None,
                                                         grantee=None, grantor=None):
                                  '''
                                  Returns a list of all security polices that match the inputs specied
                          Severity: Minor
                          Found in src/core/db/backend/pg.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 get_view_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def get_view_sql(self, repo_base, repo, table, view_params, license_id):
                                  # create view based on license
                                  license = LicenseManager.find_license_by_id(license_id)
                          
                                  pii_def = license.pii_def
                          Severity: Minor
                          Found in src/core/db/backend/pg.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 create_license_table(self):
                                  schema = settings.LICENSE_SCHEMA
                                  table = settings.LICENSE_TABLE
                                  public_role = settings.PUBLIC_ROLE
                          
                          
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 7 hrs to fix
                          src/core/db/backend/pg.py on lines 966..986

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

                          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 create_license_link_table(self):
                                  schema = settings.LICENSE_LINK_SCHEMA
                                  table = settings.LICENSE_LINK_TABLE
                                  public_role = settings.PUBLIC_ROLE
                          
                          
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 7 hrs to fix
                          src/core/db/backend/pg.py on lines 942..964

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

                          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 export_view(self, view_name, file_path, file_format='CSV',
                                              delimiter=',', header=True):
                                  words = view_name.split('.')
                                  for word in words[:-1]:
                                      self._check_for_injections(word)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 6 hrs to fix
                          src/core/db/backend/pg.py on lines 772..784

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

                          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 export_table(self, table_name, file_path, file_format='CSV',
                                               delimiter=',', header=True):
                                  words = table_name.split('.')
                                  for word in words[:-1]:
                                      self._check_for_injections(word)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 6 hrs to fix
                          src/core/db/backend/pg.py on lines 789..801

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

                          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 delete_table(self, repo, table, force=False):
                                  self._check_for_injections(repo)
                                  self._validate_table_name(table)
                          
                                  force_param = 'RESTRICT'
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 5 hrs to fix
                          src/core/db/backend/pg.py on lines 423..436

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

                          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 delete_view(self, repo, view, force=False):
                                  self._check_for_injections(repo)
                                  self._validate_table_name(view)
                          
                                  force_param = 'RESTRICT'
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 5 hrs to fix
                          src/core/db/backend/pg.py on lines 453..466

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

                          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 list_tables(self, repo):
                                  self._check_for_injections(repo)
                          
                                  all_repos = self.list_repos()
                          
                          
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 5 hrs to fix
                          src/core/db/backend/pg.py on lines 406..421

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

                          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 list_views(self, repo):
                                  self._check_for_injections(repo)
                          
                                  all_repos = self.list_repos()
                                  if repo not in all_repos:
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 5 hrs to fix
                          src/core/db/backend/pg.py on lines 357..370

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

                          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 describe_view(self, repo, view, detail=False):
                                  query = ("SELECT %s "
                                           "FROM information_schema.columns "
                                           "WHERE table_schema = %s and table_name = %s;")
                          
                          
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 372..383

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 73.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              def describe_table(self, repo, table, detail=False):
                                  query = ("SELECT %s "
                                           "FROM information_schema.columns "
                                           "WHERE table_schema = %s and table_name = %s;")
                                  params = None
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 438..451

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 73.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              def list_all_users(self):
                                  query = 'SELECT usename FROM pg_catalog.pg_user WHERE usename != %s'
                                  params = (self.user,)
                                  res = self.execute_sql(query, params)
                                  user_tuples = res['tuples']
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 655..668

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

                          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 list_all_databases(self):
                                  query = ('SELECT datname FROM pg_database where datname NOT IN '
                                           ' (%s, \'template1\', \'template0\', '
                                           ' \'datahub\', \'test_datahub\', \'postgres\');'
                                           )
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 643..653

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

                          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 create_license_schema(self):
                                  public_role = settings.PUBLIC_ROLE
                                  schema = settings.LICENSE_SCHEMA
                                  self._check_for_injections(public_role)
                                  self._check_for_injections(schema)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 1095..1103

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

                          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 create_security_policy_schema(self):
                                  public_role = settings.PUBLIC_ROLE
                                  schema = settings.POLICY_SCHEMA
                                  self._check_for_injections(public_role)
                                  self._check_for_injections(schema)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 3 hrs to fix
                          src/core/db/backend/pg.py on lines 932..940

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

                          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 _check_for_injections(self, noun):
                                  """
                                  Raises ValueError if the proposed noun is invalid.
                          
                                  Valid nouns contain only alphanumeric characters and underscores, and
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 2 hrs to fix
                          src/core/db/backend/pg.py on lines 148..165

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

                          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 _validate_table_name(self, noun):
                                  """
                                  Raises ValueError if the proposed table name is invalid.
                          
                                  Valid table names contain only alphanumeric characters and underscores.
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 2 hrs to fix
                          src/core/db/backend/pg.py on lines 128..146

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

                          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 update_security_policy(self, policy_id, new_policy, new_policy_type,
                                                         new_grantee):
                                  '''
                                  Updates an existing security policy based on the inputs specified
                                  by the user.
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
                          src/core/db/backend/pg.py on lines 988..1001

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

                          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 create_license(
                                      self, license_name, pii_def, pii_anonymized, pii_removed):
                                  '''
                                  Creates a new license
                                  '''
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
                          src/core/db/backend/pg.py on lines 1258..1271

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

                          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 database_exists(self, db_name):
                                  query = "SELECT 1 FROM pg_database WHERE datname=%s"
                                  params = (db_name,)
                                  result = self.execute_sql(query, params)
                                  return (result['row_count'] > 0)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
                          src/core/db/backend/pg.py on lines 587..591

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

                          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 user_exists(self, username):
                                  query = "SELECT 1 FROM pg_roles WHERE rolname=%s"
                                  params = (username,)
                                  result = self.execute_sql(query, params)
                                  return (result['row_count'] > 0)
                          Severity: Major
                          Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
                          src/core/db/backend/pg.py on lines 593..597

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

                          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

                                  num_rows = re.match(r'.*rows=(\d+).*', res['tuples'][0][0]).group(1)
                          Severity: Minor
                          Found in src/core/db/backend/pg.py and 1 other location - About 50 mins to fix
                          src/core/db/backend/pg.py on lines 513..513

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 36.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  byte_width = re.match(r'.*width=(\d+).*', res['tuples'][0][0]).group(1)
                          Severity: Minor
                          Found in src/core/db/backend/pg.py and 1 other location - About 50 mins to fix
                          src/core/db/backend/pg.py on lines 512..512

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 36.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Do not use bare 'except'
                          Open

                              except:
                          Severity: Minor
                          Found in src/core/db/backend/pg.py by pep8

                          When catching exceptions, mention specific exceptions when possible.

                          Okay: except Exception:
                          Okay: except BaseException:
                          E722: except:

                          Do not use bare 'except'
                          Open

                                  except:
                          Severity: Minor
                          Found in src/core/db/backend/pg.py by pep8

                          When catching exceptions, mention specific exceptions when possible.

                          Okay: except Exception:
                          Okay: except BaseException:
                          E722: except:

                          There are no issues that match your filters.

                          Category
                          Status