houston/houston-core

View on GitHub

Showing 1,937 of 1,937 total issues

Method has too many lines. [11/10]
Open

      def call(*args)
        Houston.async(invoke_async?) do
          begin
            block.call(*args)

Severity: Minor
Found in lib/houston/boot/observer.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

    Assignment Branch Condition size for format_duration is too high. [15.81/15]
    Open

      def format_duration(seconds)
        if seconds.nil?
          return "—".html_safe
        elsif seconds < 1
          "#{(seconds * 1000).floor}ms"
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for create is too high. [15.43/15]
    Open

      def create
        @user = User.new(user_params)
    
        if params[:send_invitation]
          User.invite!(params[:user])
    Severity: Minor
    Found in app/controllers/users_controller.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Block has too many lines. [37/25]
    Open

    Houston.config do
    
      # Required
      # ---------------------------------------------------------------------------
      #

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    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 _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 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 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

          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

          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

            Avoid too many return statements within this method.
            Open

                return "#{days / 7} weeks ago" if days < 63
            Severity: Major
            Found in app/helpers/application_helper.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language