datahuborg/datahub

View on GitHub
src/api/test/test_file_serializer.py

Summary

Maintainability
C
1 day
Test Coverage

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

    def setUp(self):
        self.username = "delete_me_username"
        self.repo_base = "delete_me_repo_base"
        self.password = "delete_me_password"

Severity: Major
Found in src/api/test/test_file_serializer.py and 2 other locations - About 2 hrs to fix
src/api/test/test_datahub_serializer.py on lines 11..19
src/api/test/test_query_serializer.py on lines 11..19

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

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 test_upload_file(self):
        mock_manager_save_file = self.mock_manager.return_value.save_file
        self.serializer.upload_file('repo', 'file')
        self.assertTrue(mock_manager_save_file.called)
Severity: Major
Found in src/api/test/test_file_serializer.py and 2 other locations - About 1 hr to fix
src/api/test/test_file_serializer.py on lines 38..41
src/api/test/test_file_serializer.py on lines 43..46

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 test_get_file(self):
        mock_manager_get_file = self.mock_manager.return_value.get_file
        self.serializer.get_file('repo', 'file')
        self.assertTrue(mock_manager_get_file.called)
Severity: Major
Found in src/api/test/test_file_serializer.py and 2 other locations - About 1 hr to fix
src/api/test/test_file_serializer.py on lines 33..36
src/api/test/test_file_serializer.py on lines 38..41

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 test_delete_file(self):
        mock_manager_delete_file = self.mock_manager.return_value.delete_file
        self.serializer.delete_file('repo', 'file')
        self.assertTrue(mock_manager_delete_file.called)
Severity: Major
Found in src/api/test/test_file_serializer.py and 2 other locations - About 1 hr to fix
src/api/test/test_file_serializer.py on lines 33..36
src/api/test/test_file_serializer.py on lines 43..46

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

    def test_list_files(self):
        mock_list_files = self.mock_manager.return_value.list_repo_files
        self.serializer.list_files('repo')
        self.assertTrue(mock_list_files.called)
Severity: Major
Found in src/api/test/test_file_serializer.py and 3 other locations - About 1 hr to fix
src/core/test/test_manager.py on lines 80..84
src/core/test/test_manager.py on lines 109..113
src/core/test/test_manager.py on lines 153..157

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

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/api/test/test_file_serializer.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_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_query_rewriter.py on lines 23..28
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