datahuborg/datahub

View on GitHub
src/core/db/connection.py

Summary

Maintainability
D
2 days
Test Coverage

DataHubConnection has 66 functions (exceeds 20 allowed). Consider refactoring.
Open

class DataHubConnection:

    def __init__(self, user, password, repo_base=None):
        self.backend = PGBackend(user, password, repo_base=repo_base)

Severity: Major
Found in src/core/db/connection.py - About 1 day to fix

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

        def find_security_policies(
    Severity: Major
    Found in src/core/db/connection.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,
      Severity: Major
      Found in src/core/db/connection.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/connection.py - About 50 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/connection.py - About 35 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/connection.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/connection.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/connection.py - About 35 mins to fix

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

                      def import_rows(
                  Severity: Minor
                  Found in src/core/db/connection.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/connection.py - About 35 mins to fix

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

                          def export_table(self, table_name, file_path, file_format='CSV',
                                           delimiter=',', header=True):
                              return self.backend.export_table(
                      Severity: Major
                      Found in src/core/db/connection.py and 2 other locations - About 1 hr to fix
                      src/core/db/connection.py on lines 201..203
                      src/core/db/connection.py on lines 210..212

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

                      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 export_query(self, query, file_path, file_format='CSV',
                                           delimiter=',', header=True):
                              return self.backend.export_query(
                      Severity: Major
                      Found in src/core/db/connection.py and 2 other locations - About 1 hr to fix
                      src/core/db/connection.py on lines 192..194
                      src/core/db/connection.py on lines 201..203

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

                      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 export_view(self, view_name, file_path, file_format='CSV',
                                          delimiter=',', header=True):
                              return self.backend.export_view(
                      Severity: Major
                      Found in src/core/db/connection.py and 2 other locations - About 1 hr to fix
                      src/core/db/connection.py on lines 192..194
                      src/core/db/connection.py on lines 210..212

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

                      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_view(self, repo_base, repo,
                                                  table, view_sql, license_id):
                              return self.backend.create_license_view(
                      Severity: Minor
                      Found in src/core/db/connection.py and 1 other location - About 50 mins to fix
                      src/core/db/connection.py on lines 67..68

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 36.

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

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

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

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

                      Refactorings

                      Further Reading

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

                          def get_view_sql(self, repo_base, repo, table, view_params, license_id):
                              return self.backend.get_view_sql(
                      Severity: Minor
                      Found in src/core/db/connection.py and 1 other location - About 50 mins to fix
                      src/core/db/connection.py on lines 52..54

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

                          def add_collaborator_to_license_view(
                                  self, repo, collaborator, view, db_privileges):
                      
                              return self.backend.add_collaborator_to_license_view(
                      Severity: Minor
                      Found in src/core/db/connection.py and 2 other locations - About 30 mins to fix
                      src/core/db/connection.py on lines 142..143
                      src/core/db/connection.py on lines 232..234

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 32.

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

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

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

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

                      Refactorings

                      Further Reading

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

                          def create_license(
                                  self, license_name, pii_def, pii_anonymized, pii_removed):
                              return self.backend.create_license(
                      Severity: Minor
                      Found in src/core/db/connection.py and 2 other locations - About 30 mins to fix
                      src/core/db/connection.py on lines 38..41
                      src/core/db/connection.py on lines 142..143

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 32.

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

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

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

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

                      Refactorings

                      Further Reading

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

                          def has_column_privilege(self, login, table, column, privilege):
                              return self.backend.has_column_privilege(
                      Severity: Minor
                      Found in src/core/db/connection.py and 2 other locations - About 30 mins to fix
                      src/core/db/connection.py on lines 38..41
                      src/core/db/connection.py on lines 232..234

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 32.

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

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

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

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

                      Refactorings

                      Further Reading

                      There are no issues that match your filters.

                      Category
                      Status