conan-io/conan

View on GitHub
conans/client/cmd/uploader.py

Summary

Maintainability
D
2 days
Test Coverage

Function _collect_packages_to_upload has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
Open

    def _collect_packages_to_upload(self, refs, confirm, remotes, all_packages, query, package_id):
        """ compute the references with revisions and the package_ids to be uploaded
        """
        # Group recipes by remote
        refs_by_remote = defaultdict(list)
Severity: Minor
Found in conans/client/cmd/uploader.py - About 6 hrs 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

Avoid deeply nested control flow statements.
Open

                        if ref.revision != rec_rev:
                            self._output.warn("Skipping package '%s', it doesn't belong to the"
                                              " current recipe revision" % package_id)
                            continue
                    package_revision = metadata.packages[package_id].revision
Severity: Major
Found in conans/client/cmd/uploader.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        with open(abs_path, 'rb') as file_handler:
                            tgz.addfile(tarinfo=info, fileobj=file_handler)
            tgz.close()
    Severity: Major
    Found in conans/client/cmd/uploader.py - About 45 mins to fix

      Function upload has 12 arguments (exceeds 10 allowed). Consider refactoring.
      Open

          def upload(self, reference_or_pattern, remotes, upload_recorder, package_id=None,
      Severity: Major
      Found in conans/client/cmd/uploader.py - About 45 mins to fix

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

                    if is_dirty(tgz_path):
                        self._output.warn("%s: Removing %s, marked as dirty" % (str(ref), f))
                        os.remove(tgz_path)
                        clean_dirty(tgz_path)
        Severity: Major
        Found in conans/client/cmd/uploader.py and 1 other location - About 1 hr to fix
        conans/client/cmd/uploader.py on lines 325..328

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

        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

                if is_dirty(package_tgz):
                    self._output.warn("%s: Removing %s, marked as dirty" % (str(pref), PACKAGE_TGZ_NAME))
                    os.remove(package_tgz)
                    clean_dirty(package_tgz)
        Severity: Major
        Found in conans/client/cmd/uploader.py and 1 other location - About 1 hr to fix
        conans/client/cmd/uploader.py on lines 276..279

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

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

                    error_msg = os.linesep.join("Mismatched checksum '%s' (manifest: %s, file: %s)"
                                                % (fname, h1, h2) for fname, (h1, h2) in diff.items())
        Severity: Major
        Found in conans/client/cmd/uploader.py and 1 other location - About 1 hr to fix
        conans/client/manifest_manager.py on lines 85..86

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

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

            def __init__(self, cache, user_io, output, loader):
                self._cache = cache
                self._user_io = user_io
                self._output = output
                self._loader = loader
        Severity: Major
        Found in conans/client/cmd/uploader.py and 5 other locations - About 1 hr to fix
        conans/client/cmd/uploader.py on lines 154..158
        conans/client/graph/python_requires.py on lines 16..21
        conans/client/remote_manager.py on lines 49..53
        conans/client/remover.py on lines 84..88
        conans/client/rest/file_uploader.py on lines 15..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 38.

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

            def __init__(self, cache, remote_manager, hook_manager, output):
                self._cache = cache
                self._remote_manager = remote_manager
                self._output = output
                self._hook_manager = hook_manager
        Severity: Major
        Found in conans/client/cmd/uploader.py and 5 other locations - About 1 hr to fix
        conans/client/cmd/uploader.py on lines 45..49
        conans/client/graph/python_requires.py on lines 16..21
        conans/client/remote_manager.py on lines 49..53
        conans/client/remover.py on lines 84..88
        conans/client/rest/file_uploader.py on lines 15..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 38.

        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

                    tgz_files = {f: path for f, path in files.items() if
                                 f not in [CONANINFO, CONAN_MANIFEST]}
        Severity: Minor
        Found in conans/client/cmd/uploader.py and 1 other location - About 35 mins to fix
        conans/client/rest/rest_client_common.py on lines 27..28

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

        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

        Line too long (101 > 100 characters)
        Open

                files_to_upload, deleted = self._package_files_to_upload(pref, policy, cache_files, p_remote)
        Severity: Minor
        Found in conans/client/cmd/uploader.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (101 > 100 characters)
        Open

                files_to_upload, deleted, cache_files, conanfile_path, t1, current_remote_name, layout = prep
        Severity: Minor
        Found in conans/client/cmd/uploader.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Too many blank lines (14)
        Open

        def compress_files(files, symlinks, name, dest_dir, output=None):
        Severity: Minor
        Found in conans/client/cmd/uploader.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (101 > 100 characters)
        Open

                return files_to_upload, deleted, cache_files, conanfile_path, t1, current_remote_name, layout
        Severity: Minor
        Found in conans/client/cmd/uploader.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        There are no issues that match your filters.

        Category
        Status