datahuborg/datahub

View on GitHub
src/core/test/test_query_rewriter.py

Summary

Maintainability
B
5 hrs
Test Coverage

File test_query_rewriter.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from core.db.query_rewriter import SQLQueryRewriter

from django.db.models import signals
from django.test import TestCase

Severity: Minor
Found in src/core/test/test_query_rewriter.py - About 3 hrs to fix

    Function test_apply_row_level_security_base has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def test_apply_row_level_security_base(self):
            mock_find_table_policies = self.create_patch(
                'core.db.query_rewriter.SQLQueryRewriter.find_table_policies')
            mock_find_table_policies.return_value = ["tester='Alice'"]
    
    
    Severity: Minor
    Found in src/core/test/test_query_rewriter.py - About 1 hr to fix

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

          def create_patch(self, name):
              # helper method for creating patches
              patcher = patch(name)
              thing = patcher.start()
              self.addCleanup(patcher.stop)
      Severity: Major
      Found in src/core/test/test_query_rewriter.py and 17 other locations - About 1 hr to fix
      src/api/test/test_collaborator_serializer.py on lines 24..29
      src/api/test/test_datahub_serializer.py on lines 21..26
      src/api/test/test_file_serializer.py on lines 21..26
      src/api/test/test_query_serializer.py on lines 21..26
      src/api/test/test_repo_serializer.py on lines 24..29
      src/api/test/test_table_serializer.py on lines 24..29
      src/api/test/test_view_serializer.py on lines 25..30
      src/browser/test/test_repo_views.py on lines 50..55
      src/browser/test/test_repo_views.py on lines 126..131
      src/browser/test/test_repo_views.py on lines 216..221
      src/browser/test/test_repo_views.py on lines 258..263
      src/browser/test/test_repo_views.py on lines 301..306
      src/core/test/test_manager.py on lines 26..31
      src/core/test/test_manager.py on lines 65..70
      src/core/test/test_manager.py on lines 229..234
      src/core/test/test_rls_permissions.py on lines 19..24
      src/core/test/test_rlsmanager.py on lines 24..29

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 39.

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

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

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

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

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status