Sha256: 7f17acdb6a909648e86fe349da1d5c51be176bf708543553613c4eb4aef788cb

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8
module RailsBestPractices
  module Core
    # Error is the violation to rails best practice.
    #
    # it indicates the filenname, line number and error message for the violation.
    class Error
      attr_reader :filename, :line_number, :message, :type, :url
      attr_accessor :git_commit, :git_username, :hg_commit, :hg_username

      def initialize(filename, line_number, message, type, url = nil)
        @filename = filename
        @line_number = line_number
        @message = message
        @type = type
        @url = url
      end

      def short_filename
        File.expand_path(filename)[File.expand_path(Core::Runner.base_path).size..-1].sub(/^\//, '')
      end

      def first_line_number
        line_number.split(',').first
      end

      def to_s
        "#{@filename}:#{@line_number} - #{@message}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_best_practices-1.7.2 lib/rails_best_practices/core/error.rb
rails_best_practices-1.7.1 lib/rails_best_practices/core/error.rb
rails_best_practices-1.7.0 lib/rails_best_practices/core/error.rb
rails_best_practices-1.6.0 lib/rails_best_practices/core/error.rb