avocado-framework/avocado

View on GitHub
selftests/unit/utils/test_archive.py

Summary

Maintainability
F
3 days
Test Coverage

ArchiveTest has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class ArchiveTest(unittest.TestCase):

    def setUp(self):
        prefix = temp_dir_prefix(self)
        self.basedir = tempfile.TemporaryDirectory(prefix=prefix)
Severity: Minor
Found in selftests/unit/utils/test_archive.py - About 3 hrs to fix

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

        def compress_and_check_dir(self, extension):
            hash_map_1 = {}
            for i in range(self.sys_random.randint(10, 20)):
                if i % 2 == 0:
                    compressdir = tempfile.mkdtemp(dir=self.compressdir)
    Severity: Minor
    Found in selftests/unit/utils/test_archive.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

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

        def test_uncompress_lzma(self):
            xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
            ret = archive.uncompress(xz_path, self.decompressdir)
            self.assertEqual(ret, os.path.join(self.decompressdir, 'avocado'))
            with open(ret, 'rb') as decompressed:
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 4 hrs to fix
    selftests/unit/utils/test_archive.py on lines 173..178

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

    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 test_uncompress_gzip(self):
            gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
            ret = archive.uncompress(gz_path, self.decompressdir)
            self.assertEqual(ret, os.path.join(self.decompressdir, 'avocado'))
            with open(ret, 'rb') as decompressed:
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 4 hrs to fix
    selftests/unit/utils/test_archive.py on lines 205..210

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

    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 test_lzma_uncompress_to_file(self):
            xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
            filename = os.path.join(self.decompressdir, 'other')
            ret = archive.lzma_uncompress(xz_path, filename)
            self.assertEqual(ret, filename)
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/test_archive.py on lines 163..167

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

        def test_gzip_uncompress_to_file(self):
            gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
            filename = os.path.join(self.decompressdir, 'other')
            ret = archive.gzip_uncompress(gz_path, filename)
            self.assertEqual(ret, filename)
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/test_archive.py on lines 192..196

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

        def test_gzip_uncompress_to_dir(self):
            gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
            ret = archive.gzip_uncompress(gz_path, self.decompressdir)
            self.assertEqual(ret, os.path.join(self.decompressdir, 'avocado'))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/test_archive.py on lines 187..190

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

    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 test_lzma_uncompress_to_dir(self):
            xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
            ret = archive.lzma_uncompress(xz_path, self.decompressdir)
            self.assertEqual(ret, os.path.join(self.decompressdir, 'avocado'))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/test_archive.py on lines 158..161

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

    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_gzip_is_archive(self):
            gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
            self.assertTrue(archive.is_archive(gz_path))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 3 other locations - About 55 mins to fix
    selftests/unit/utils/test_archive.py on lines 154..156
    selftests/unit/utils/test_archive.py on lines 180..182
    selftests/unit/utils/test_archive.py on lines 198..200

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

    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_is_lzma_file(self):
            xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
            self.assertTrue(archive.is_lzma_file(xz_path))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 3 other locations - About 55 mins to fix
    selftests/unit/utils/test_archive.py on lines 154..156
    selftests/unit/utils/test_archive.py on lines 169..171
    selftests/unit/utils/test_archive.py on lines 198..200

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

    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_is_gzip_file(self):
            gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
            self.assertTrue(archive.is_gzip_file(gz_path))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 3 other locations - About 55 mins to fix
    selftests/unit/utils/test_archive.py on lines 169..171
    selftests/unit/utils/test_archive.py on lines 180..182
    selftests/unit/utils/test_archive.py on lines 198..200

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

    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_lzma_is_archive(self):
            xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
            self.assertTrue(archive.is_archive(xz_path))
    Severity: Major
    Found in selftests/unit/utils/test_archive.py and 3 other locations - About 55 mins to fix
    selftests/unit/utils/test_archive.py on lines 154..156
    selftests/unit/utils/test_archive.py on lines 169..171
    selftests/unit/utils/test_archive.py on lines 180..182

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

    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