wied03/centos-package-cron

View on GitHub

Showing 19 of 19 total issues

File runtests.py has 3027 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! /usr/bin/env python

sources = """
eNrsvWt3G1l2KDb35nFjJNd2kpt8S1YNFLqqJBCiNG17jNvosUYtjWXPdPeS1J724vBCRVSRrCZQ
BVUVRDLjycrKf8jKx/yI/Ij8rezXedYpAFQ/xl4rbY9IAufs89pnv85+/O//9g/vf5J8/eebu+li
Severity: Major
Found in runtests.py - About 1 wk to fix

    Function _add_general_updates_to_email has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _add_general_updates_to_email(self, general_updates, email_body):
            if len(general_updates) > 0:
                email_body += u"The following packages are available for updating:\n\n"
    
            for update in general_updates:
    Severity: Minor
    Found in centos_package_cron/report_producer.py - About 1 hr 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

            if len(self.repos_to_exclude) > 0:
                repos_flat = "--disablerepo=%s" % (','.join(self.repos_to_exclude))
                args.append(repos_flat)
    Severity: Major
    Found in centos_package_cron/package_fetcher.py and 1 other location - About 1 hr to fix
    centos_package_cron/package_fetcher.py on lines 86..88

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

    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 len(self.repos_to_include) > 0:
                repos_flat = "--enablerepo=%s" % (','.join(self.repos_to_include))
                args.append(repos_flat)
    Severity: Major
    Found in centos_package_cron/package_fetcher.py and 1 other location - About 1 hr to fix
    centos_package_cron/package_fetcher.py on lines 83..85

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

    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

    Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in centos_package_cron/report_producer.py - About 1 hr to fix

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

                  associated_package_labels = map(lambda pkg: "* %s-%s-%s" % (pkg.name, pkg.version, pkg.release),advisory_and_package['installed_packages'])
      Severity: Major
      Found in centos_package_cron/report_producer.py and 1 other location - About 1 hr to fix
      centos_package_cron/report_producer.py on lines 70..70

      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

                  associated_package_labels = map(lambda pkg: "%s-%s-%s" % (pkg.name, pkg.version, pkg.release), advisory_and_package['installed_packages'])
      Severity: Major
      Found in centos_package_cron/report_producer.py and 1 other location - About 1 hr to fix
      centos_package_cron/report_producer.py on lines 50..50

      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

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,advisory_id,type,severity,architectures,releases,packages,references):
      Severity: Major
      Found in centos_package_cron/errata_item.py - About 50 mins to fix

        Function __enter__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __enter__(self):
                if self.engine == None:
                    absolute_path = os.path.abspath(self.db_path)
                    parent_dir = os.path.dirname(absolute_path)
                    if not os.path.exists(parent_dir):
        Severity: Minor
        Found in centos_package_cron/db_session_fetcher.py - About 45 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

        Function main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def main():
            args = parse_args()
            if args.output not in ['email', 'stdout']:
                print "%s is not valid for the -o/--output parameter. Must be email or stdout" % (args.output)
                raise
        Severity: Minor
        Found in centos_package_cron/command_line.py - About 45 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

                result = map(lambda x: Package(x.name,x.version,x.release, x.arch, x.repoid), packages)
        Severity: Minor
        Found in centos_package_cron/package_fetcher.py and 1 other location - About 40 mins to fix
        centos_package_cron/package_fetcher.py on lines 62..62

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

        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

                result = map(lambda x: Package(x.name,x.version,x.release, x.arch, x.repoid), raw_updates)
        Severity: Minor
        Found in centos_package_cron/package_fetcher.py and 1 other location - About 40 mins to fix
        centos_package_cron/package_fetcher.py on lines 57..57

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

        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

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

            def __init__(self,name,version,release,arch,repository):
        Severity: Minor
        Found in centos_package_cron/package.py - About 35 mins to fix

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

                  existing = self.session.query(Package).filter(Package.name == package.name).all()            
          Severity: Minor
          Found in centos_package_cron/annoyance_check.py and 1 other location - About 35 mins to fix
          centos_package_cron/annoyance_check.py on lines 10..10

          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

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

                  existing = self.session.query(ErrataItem).filter(ErrataItem.advisory_id == advisory.advisory_id).all()          
          Severity: Minor
          Found in centos_package_cron/annoyance_check.py and 1 other location - About 35 mins to fix
          centos_package_cron/annoyance_check.py on lines 19..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 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

          Avoid too many return statements within this function.
          Open

                  return urllib2.build_opener(http_proxy_handler, proxy_auth_handler)
          Severity: Major
          Found in centos_package_cron/errata_fetcher.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return urllib2.build_opener(http_proxy_handler)
            Severity: Major
            Found in centos_package_cron/errata_fetcher.py - About 30 mins to fix

              Function get_opener has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_opener():
                  default_opener = urllib2.build_opener()
                  if not exists(YUM_CONF):
                      return default_opener
                  config = RawConfigParser()
              Severity: Minor
              Found in centos_package_cron/errata_fetcher.py - About 25 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

              Function _add_changelogs_to_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _add_changelogs_to_email(self, general_updates, email_body):
                      if len(general_updates) > 0:
                          changelogs = map(lambda pkg: { 'name': pkg.name, 'changelog': self.pkg_fetcher.get_package_changelog(pkg.name,pkg.version,pkg.release)},general_updates)
                          email_body += u"\n\nChange logs for available package updates:\n\n"
              
              
              Severity: Minor
              Found in centos_package_cron/report_producer.py - About 25 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

              Severity
              Category
              Status
              Source
              Language