BaseSecrete/rorvswild

View on GitHub

Showing 20 of 20 total issues

Class Agent has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Agent
    def self.default_config
      {
        api_url: "https://www.rorvswild.com/api/v1",
        ignore_exceptions: default_ignored_exceptions,
Severity: Minor
Found in lib/rorvswild/agent.rb - About 3 hrs to fix

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

    RorVsWild.Local.prototype.getRequests = function(callback) {
      this.getJson("/rorvswild/requests.json", function(data) {
        this.requests = data.map(function(attributes) { return new RorVsWild.Local.Request(attributes) })
        callback()
      }.bind(this))
    Severity: Major
    Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 3 hrs to fix
    lib/rorvswild/local/javascript/local.js on lines 21..26
    lib/rorvswild/local/javascript/local.js on lines 28..33

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

    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

    RorVsWild.Local.prototype.getErrors = function(callback) {
      this.getJson("/rorvswild/errors.json", function(data) {
        this.errors = data.map(function(attributes) { return new RorVsWild.Local.Error(attributes) })
        callback()
      }.bind(this))
    Severity: Major
    Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 3 hrs to fix
    lib/rorvswild/local/javascript/local.js on lines 14..19
    lib/rorvswild/local/javascript/local.js on lines 21..26

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

    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

    RorVsWild.Local.prototype.getJobs = function(callback) {
      this.getJson("/rorvswild/jobs.json", function(data) {
        this.jobs = data.map(function(attributes) { return new RorVsWild.Local.Request(attributes) })
        callback()
      }.bind(this))
    Severity: Major
    Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 3 hrs to fix
    lib/rorvswild/local/javascript/local.js on lines 14..19
    lib/rorvswild/local/javascript/local.js on lines 28..33

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

    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

    RorVsWild.Local.prototype.goToErrorDetail = function(event) {
      var uuid = event.currentTarget.dataset.uuid
      this.currentError = this.errors.find(function(err) { return err.uuid == uuid })
      this.render("ErrorDetail")
    }
    Severity: Major
    Found in lib/rorvswild/local/javascript/local.js and 1 other location - About 3 hrs to fix
    lib/rorvswild/local/javascript/local.js on lines 133..137

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

    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

    RorVsWild.Local.prototype.goToJobDetail = function(event) {
      var uuid = event.currentTarget.dataset.uuid
      this.currentJob = this.jobs.find(function(job) { return job.uuid == uuid })
      this.render("JobDetail")
    }
    Severity: Major
    Found in lib/rorvswild/local/javascript/local.js and 1 other location - About 3 hrs to fix
    lib/rorvswild/local/javascript/local.js on lines 144..148

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

    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

    File local.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var RorVsWild = this.RorVsWild = {};
    
    RorVsWild.Local = function(container) {
      this.root = container
      this.active = false
    Severity: Minor
    Found in lib/rorvswild/local/javascript/local.js - About 2 hrs to fix

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

      RorVsWild.Local.prototype.goToRequestIndex = function(event) {
        this.root.dataset.tab = "requests"
        this.getRequests(function() { this.render("RequestIndex") }.bind(this))
      }
      Severity: Major
      Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 2 hrs to fix
      lib/rorvswild/local/javascript/local.js on lines 128..131
      lib/rorvswild/local/javascript/local.js on lines 139..142

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

      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

      RorVsWild.Local.prototype.goToJobIndex = function(event) {
        this.root.dataset.tab = "jobs"
        this.getJobs(function() { this.render("JobIndex") }.bind(this))
      }
      Severity: Major
      Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 2 hrs to fix
      lib/rorvswild/local/javascript/local.js on lines 123..126
      lib/rorvswild/local/javascript/local.js on lines 139..142

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

      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

      RorVsWild.Local.prototype.goToErrors = function(event) {
        this.root.dataset.tab = "errors"
        this.getErrors(function() { this.render("ErrorIndex") }.bind(this))
      }
      Severity: Major
      Found in lib/rorvswild/local/javascript/local.js and 2 other locations - About 2 hrs to fix
      lib/rorvswild/local/javascript/local.js on lines 123..126
      lib/rorvswild/local/javascript/local.js on lines 128..131

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

      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

      Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice)
      Severity: Major
      Found in lib/rorvswild/metrics/cpu.rb - About 1 hr to fix

        Method setup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.setup
                return if @installed
                return unless defined?(Delayed::Plugin)
                Delayed::Worker.plugins << Class.new(Delayed::Plugin) do
                  callbacks do |lifecycle|
        Severity: Minor
        Found in lib/rorvswild/plugin/delayed_job.rb - About 55 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 serve_embed_profiler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def serve_embed_profiler(env)
                status, headers, body = app.call(env)
                status = status.to_i
                if status >= 200 && status < 300 && headers["Content-Type"] && headers["Content-Type"].include?("text/html")
                  if headers["Content-Encoding"]
        Severity: Minor
        Found in lib/rorvswild/local/middleware.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 read_from_capistrano has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.read_from_capistrano
              return unless File.readable?("REVISION")
              return unless @revision = File.read("REVISION")
              return unless stdout = shell("git --git-dir ../../repo log --format=%an%n%ae%n%B -n 1 #{@revision}")
              lines = stdout.lines
        Severity: Minor
        Found in lib/rorvswild/deployment.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 setup_plugins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_plugins
              for name in RorVsWild::Plugin.constants
                next if config[:ignore_plugins] && config[:ignore_plugins].include?(name.to_s)
                if (plugin = RorVsWild::Plugin.const_get(name)).respond_to?(:setup)
                  RorVsWild.logger.debug("Setup RorVsWild::Plugin::#{name}")
        Severity: Minor
        Found in lib/rorvswild/agent.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 transmit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def transmit(request)
              if !@http_unauthorized && http = take_or_create_connection
                response = http.request(request)
                @http_unauthorized = true if response.code == "401"
                response
        Severity: Minor
        Found in lib/rorvswild/client.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

        Avoid too many return statements within this function.
        Open

            return Number(value.toFixed(0))
        Severity: Major
        Found in lib/rorvswild/local/javascript/local.js - About 30 mins to fix

          Method inject_into has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def inject_into(html)
                  if index = html.index("</body>")
                    markup = File.read(File.join(LOCAL_FOLDER, "local.html.erb"))
                    markup = ERB.new(markup).result(binding)
                    markup = markup.html_safe if markup.respond_to?(:html_safe)
          Severity: Minor
          Found in lib/rorvswild/local/middleware.rb - 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

          Method update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def update
                  if @old_stat && (new_stat = Stat.read)
                    if (total = new_stat.total - @old_stat.total) > 0
                      @user = (new_stat.user - @old_stat.user) * 100 / total
                      @system = (new_stat.system - @old_stat.system) * 100 / total
          Severity: Minor
          Found in lib/rorvswild/metrics/cpu.rb - 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

          Method parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.parse(string)
                    for row in string.lines
                      if row.start_with?("cpu ")
                        array = row.split[1..-1].map(&:to_i)[0,10]
                        array.fill(0, array.size, 10 - array.size) if array.size < 10
          Severity: Minor
          Found in lib/rorvswild/metrics/cpu.rb - 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