houston/houston-core

View on GitHub

Showing 1,937 of 1,937 total issues

Assignment Branch Condition size for _add_white_space is too high. [17.2/15]
Open

  def _add_white_space(json)
    scanner = StringScanner.new(json)
    output = ""
    indent = 0
    until scanner.eos?
Severity: Minor
Found in app/helpers/actions_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 show is too high. [17.38/15]
Open

  def show
    authorize! :read, Action
    @action_name = params[:slug]
    @actions = Action.where(name: @action_name).preload(:error).limit(50)
    @actions = @actions.where(Action.arel_table[:created_at].lt(params[:before])) if params[:before]

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

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

  def user_params
    params.permit(user: [
      :first_name,
      :last_name,
      :email,
Severity: Minor
Found in app/controllers/users_controller.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 has too many lines. [12/10]
Open

  def api_authenticate!
    return if current_user

    allow_params_authentication!
    authenticate_or_request_with_http_basic do |username, password|

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.

Assignment Branch Condition size for copy_files is too high. [17.29/15]
Open

    def copy_files
      path = source_paths[0]
      path_length = path.length + 1
      Dir.glob(path + "/**/*", File::FNM_DOTMATCH).each do |file|
        next if File.directory?(file)

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

Method has too many lines. [12/10]
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|

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.

Perceived complexity for daemonize is too high. [9/7]
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 by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for add_to_project_features is too high. [17.58/15]
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|

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 try is too high. [17.69/15]
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 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

Cyclomatic complexity for debug is too high. [7/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for take! is too high. [16.61/15]
Open

    def take!(attributes)
      required_keys = [:subject_type, :subject_id, :taken_at, :name].freeze

      identifying_attributes = attributes.pick(required_keys)
      subject = attributes[:subject]
Severity: Minor
Found in app/models/measurement.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

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

    def get_prop(prop_name)
      Houston::Props.valid_prop_name!(prop_name)
      value = props[prop_name]

      if !value && block_given?
Severity: Minor
Found in app/concerns/houston/props.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 has too many lines. [11/10]
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 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.

Cyclomatic complexity for _add_white_space is too high. [7/6]
Open

  def _add_white_space(json)
    scanner = StringScanner.new(json)
    output = ""
    indent = 0
    until scanner.eos?
Severity: Minor
Found in app/helpers/actions_helper.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for update is too high. [16.16/15]
Open

  def update
    @team.props.merge! team_attributes.delete(:props) if team_attributes.key?(:props)

    if @team.update_attributes(team_attributes)
      redirect_to teams_path, notice: "Team was successfully updated."
Severity: Minor
Found in app/controllers/teams_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

Method has too many lines. [11/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for index is too high. [16.25/15]
Open

  def index
    authorize! :read, Action
    @actions = Action.where.not(error_id: nil).preload(:error).limit(50)
    @actions = @actions.where(Action.arel_table[:created_at].lt(params[:before])) if params[:before]
    render partial: "actions/actions" if request.xhr?

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

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

  def update
    @user = User.find(params[:id])
    @user.role = @role

    attributes = user_params
Severity: Minor
Found in app/controllers/users_controller.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 has too many lines. [11/10]
Open

      def add(content, &path_block)
        if content.is_a?(Symbol)
          slug = content
          content = slug.to_s.titleize
        else

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.

Cyclomatic complexity for try is too high. [7/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Severity
Category
Status
Source
Language