houston/houston-core

View on GitHub

Showing 27 of 1,937 total issues

Class Configuration has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Configuration
    attr_reader :observer, :actions, :timer, :oauth_providers

    def initialize
      @root = Rails.root
Severity: Minor
Found in lib/houston/boot/configuration.rb - About 5 hrs to fix

    File configuration.rb has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    root = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
    require File.join(root, "lib/hash_dsl")
    require File.join(root, "lib/core_ext/hash")
    require File.join(root, "lib/core_ext/kernel")
    require File.join(root, "lib/core_ext/exception")
    Severity: Minor
    Found in lib/houston/boot/configuration.rb - About 4 hrs to fix

      Method pack has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def pack(object)
            case object
            when Array
              object.map { |item| pack(item) }
            when Hash
      Severity: Minor
      Found in lib/houston/boot/serializer.rb - About 2 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

      Method daemonize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.daemonize(name)
          unless Houston.running_as_web_server? or ENV["HOUSTON_DAEMONS"].to_s.split(",").member?(name)
            puts "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m" if Rails.env.development?
            Rails.logger.info "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m"
            return
      Severity: Minor
      Found in lib/houston/boot/daemonize.rb - About 2 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

      Method score has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def score(label, value, options={})
          score_count_class = Array(options.delete(:score_count_class)) << "score-count"
          precision = options.delete(:precision)
      
          css = Array(options.fetch(:class, []))
      Severity: Minor
      Found in app/helpers/score_card_helper.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 mail has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def mail(options={})
          options[:from] = format_email_addresses(options[:from]) if options.key?(:from)
          options[:to] = format_email_addresses(options[:to]).uniq if options.key?(:to)
          options[:cc] = format_email_addresses(options[:cc]).uniq if options.key?(:cc)
          options[:bcc] = format_email_addresses(options[:bcc]).uniq if options.key?(:bcc)
      Severity: Minor
      Found in app/mailers/view_mailer.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 define_methods! has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def define_methods!
            concern = ProjectAdapter.const_set(concern_name, Module.new)
            concern.extend ActiveSupport::Concern
      
            class_methods = concern.const_set(:ClassMethods, Module.new)
      Severity: Minor
      Found in app/concerns/project_adapter.rb - About 1 hr to fix

        Method try has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.try(options, *rescue_from)
            options = { max_tries: options } if options.is_a?(Fixnum)
            options = {} unless options.is_a?(Hash)
            max_tries = options.fetch :max_tries, 3
            base = options.fetch :base, 2
        Severity: Minor
        Found in lib/houston/try.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 pack has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def pack(object)
              case object
              when Array
                object.map { |item| pack(item) }
              when Hash
        Severity: Minor
        Found in lib/houston/boot/serializer.rb - About 1 hr to fix

          Method run! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run!
              exception = nil
          
              Houston.reconnect do
                touch :started_at
          Severity: Minor
          Found in app/models/action.rb - About 1 hr to fix

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

                def root(*args)
                  if args.any?
                    @root = args.first
            
                    # Keep structure.sql in instances' db directory
            Severity: Minor
            Found in lib/houston/boot/configuration.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 debug has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def debug(colored: true)
                  format_subject = ->(s) { s.is_a?(User) ? s.first_name : s.is_a?(Project) ? s.slug : "" }
                  includes(:subject).reorder("taken_at ASC, subject_type ASC, subject_id ASC, name ASC").map { |m|
                    line = [ m.taken_on.strftime("%-m/%-d").rjust(5),
                             m.taken_at.strftime("%H:%M:%S"),
            Severity: Minor
            Found in app/models/measurement.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 policies has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def policies
                ext = File.extname(params[:name])
                unique_file_name = params.values_at(:name, :size, :type).join(".")
                filename = Digest::SHA1.hexdigest(unique_file_name) + ext
                object_name = "uploads/#{current_user.id}/#{filename}"
            Severity: Minor
            Found in app/controllers/uploads_controller.rb - About 1 hr to fix

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

                      def add_to_project_features(slug)
                        raise ArgumentError, "Project Feature must supply name, but #{slug.inspect} doesn't" unless @name
                        raise ArgumentError, "Project Feature must supply path lambda, but #{slug.inspect} doesn't" unless @path_block
              
                        Houston.project_features.add(slug, &@path_block).tap do |feature|
              Severity: Minor
              Found in lib/houston/boot/extensions/deprecated.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 has_adapter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def has_adapter(*adapter_namespaces)
                  adapter_namespaces.each do |adapter_namespace|
                    adapter_module = Houston::Adapters[adapter_namespace]
                    raise ArgumentError, "#{adapter_module} should respond to `adapters`" unless adapter_module.respond_to?(:adapters)
                    raise ArgumentError, "#{adapter_module} should respond to `adapter`" unless adapter_module.respond_to?(:adapter)
              Severity: Minor
              Found in app/concerns/project_adapter.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 _format_time_ago has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def _format_time_ago(time)
                  duration = (Time.now - time).to_i
                  return "#{duration} seconds ago" if duration < 90.seconds
                  return "#{duration / 60} minutes ago" if duration < 90.minutes
                  return "%.1f hours ago" % (duration / 3600.0) if duration < 20.hours
              Severity: Minor
              Found in app/helpers/application_helper.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 unpack has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def unpack(object)
                    if object.is_a?(Array)
                      object.map { |item| unpack(item) }
                    elsif object.is_a?(Hash)
                      object = object.each_with_object({}) { |(key, value), new_object| new_object[key] = unpack(value) }
              Severity: Minor
              Found in lib/houston/boot/serializer.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 format_time has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def format_time(time, options={})
                  if time.nil?
                    date, time = ["", "Never"]
                  elsif time.to_date == Date.today
                    date, time = [options[:today] ? "Today" : "", time.strftime("%l:%M %p")]
              Severity: Minor
              Found in app/helpers/application_helper.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(user)
                  if user
              
                    # Owners can do everything
              
              
              Severity: Minor
              Found in app/models/ability.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 method.
              Open

                  return ">1 year ago" if days < 730
              Severity: Major
              Found in app/helpers/application_helper.rb - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language