hackedteam/rcs-collector

View on GitHub
lib/rcs-collector/db.rb

Summary

Maintainability
F
3 days
Test Coverage

Class DB has 49 methods (exceeds 20 allowed). Consider refactoring.
Open

class DB
  include Singleton
  include RCS::Tracer

  ACTIVE_AGENT = 0
Severity: Minor
Found in lib/rcs-collector/db.rb - About 6 hrs to fix

    Method cache_init has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      def cache_init
        # if the db is available, clear the cache and populate it again
        if @available
          # get the global signature (per customer) for all the agents
          bck_sig = db_rest_call :agent_signature
    Severity: Minor
    Found in lib/rcs-collector/db.rb - About 5 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

    File db.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'config.rb'
    require_relative 'db_rest.rb'
    require_relative 'db_cache.rb'
    require_relative 'my_ip.rb'
    
    
    Severity: Minor
    Found in lib/rcs-collector/db.rb - About 5 hrs to fix

      Method cache_init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cache_init
          # if the db is available, clear the cache and populate it again
          if @available
            # get the global signature (per customer) for all the agents
            bck_sig = db_rest_call :agent_signature
      Severity: Minor
      Found in lib/rcs-collector/db.rb - About 1 hr to fix

        Method agent_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def agent_status(build_id, instance_id, platform, demo, level)
            # if the database has gone, reply with a fake response in order for the sync to continue
            return agent_cached_status(build_id) unless @available
        
            trace :debug, "Asking the status of [#{build_id}_#{instance_id}] to the db"
        Severity: Minor
        Found in lib/rcs-collector/db.rb - 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

        Method update_status has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def update_status(component, ip, status, message, stats, type, version)
        Severity: Major
        Found in lib/rcs-collector/db.rb - About 50 mins to fix

          Method new_downloads? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def new_downloads?(bid)
              # check if we have the downloads in the cache
              # probably and old one not yet sent
              return true if DBCache.new_downloads? bid
              # cannot reach the db, return false
          Severity: Minor
          Found in lib/rcs-collector/db.rb - 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

          Method sync_update has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def sync_update(session, version, user, device, source, time)
          Severity: Minor
          Found in lib/rcs-collector/db.rb - About 45 mins to fix

            Method new_filesystems? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def new_filesystems?(bid)
                # check if we have the filesystems in the cache
                # probably and old one not yet sent
                return true if DBCache.new_filesystems? bid
                # cannot reach the db, return false
            Severity: Minor
            Found in lib/rcs-collector/db.rb - 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

            Method new_uploads? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def new_uploads?(bid)
                # check if we have the uploads in the cache
                # probably and old one not yet sent
                return true if DBCache.new_uploads? bid
                # cannot reach the db, return false
            Severity: Minor
            Found in lib/rcs-collector/db.rb - 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

            Method sync_start has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def sync_start(session, version, user, device, source, time)
            Severity: Minor
            Found in lib/rcs-collector/db.rb - About 45 mins to fix

              Method new_exec? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def new_exec?(bid)
                  # check if we have any exec in the cache
                  # probably and old one not yet sent
                  return true if DBCache.new_exec? bid
                  # cannot reach the db, return false
              Severity: Minor
              Found in lib/rcs-collector/db.rb - 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

              Method agent_status has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def agent_status(build_id, instance_id, platform, demo, level)
              Severity: Minor
              Found in lib/rcs-collector/db.rb - About 35 mins to fix

                Method new_conf? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def new_conf?(bid)
                    # check if we have the config in the cache
                    # probably and old one not yet sent
                    return true if DBCache.new_conf? bid
                    # cannot reach the db, return false
                Severity: Minor
                Found in lib/rcs-collector/db.rb - 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

                Method new_upgrade? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def new_upgrade?(bid)
                    # cannot reach the db, return false
                    return false unless @available
                
                    # remove any pending entry in the cache
                Severity: Minor
                Found in lib/rcs-collector/db.rb - 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 4 locations. Consider refactoring.
                Open

                  def new_downloads?(bid)
                    # check if we have the downloads in the cache
                    # probably and old one not yet sent
                    return true if DBCache.new_downloads? bid
                    # cannot reach the db, return false
                Severity: Major
                Found in lib/rcs-collector/db.rb and 3 other locations - About 35 mins to fix
                lib/rcs-collector/db.rb on lines 362..376
                lib/rcs-collector/db.rb on lines 466..480
                lib/rcs-collector/db.rb on lines 524..538

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

                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 new_exec?(bid)
                    # check if we have any exec in the cache
                    # probably and old one not yet sent
                    return true if DBCache.new_exec? bid
                    # cannot reach the db, return false
                Severity: Major
                Found in lib/rcs-collector/db.rb and 3 other locations - About 35 mins to fix
                lib/rcs-collector/db.rb on lines 362..376
                lib/rcs-collector/db.rb on lines 429..443
                lib/rcs-collector/db.rb on lines 466..480

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

                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 new_filesystems?(bid)
                    # check if we have the filesystems in the cache
                    # probably and old one not yet sent
                    return true if DBCache.new_filesystems? bid
                    # cannot reach the db, return false
                Severity: Major
                Found in lib/rcs-collector/db.rb and 3 other locations - About 35 mins to fix
                lib/rcs-collector/db.rb on lines 362..376
                lib/rcs-collector/db.rb on lines 429..443
                lib/rcs-collector/db.rb on lines 524..538

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

                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 new_uploads?(bid)
                    # check if we have the uploads in the cache
                    # probably and old one not yet sent
                    return true if DBCache.new_uploads? bid
                    # cannot reach the db, return false
                Severity: Major
                Found in lib/rcs-collector/db.rb and 3 other locations - About 35 mins to fix
                lib/rcs-collector/db.rb on lines 429..443
                lib/rcs-collector/db.rb on lines 466..480
                lib/rcs-collector/db.rb on lines 524..538

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

                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 new_filesystems(bid)
                    # retrieve the filesystems from the cache
                    filesystems = DBCache.new_filesystems bid
                
                    return [] if filesystems.empty?
                Severity: Minor
                Found in lib/rcs-collector/db.rb and 2 other locations - About 30 mins to fix
                lib/rcs-collector/db.rb on lines 445..463
                lib/rcs-collector/db.rb on lines 540..558

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

                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 new_exec(bid)
                    # retrieve the downloads from the cache
                    commands = DBCache.new_exec bid
                
                    return [] if commands.empty?
                Severity: Minor
                Found in lib/rcs-collector/db.rb and 2 other locations - About 30 mins to fix
                lib/rcs-collector/db.rb on lines 445..463
                lib/rcs-collector/db.rb on lines 482..500

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

                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 new_downloads(bid)
                    # retrieve the downloads from the cache
                    downloads = DBCache.new_downloads bid
                
                    return [] if downloads.empty?
                Severity: Minor
                Found in lib/rcs-collector/db.rb and 2 other locations - About 30 mins to fix
                lib/rcs-collector/db.rb on lines 482..500
                lib/rcs-collector/db.rb on lines 540..558

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

                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