Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rubocop/git/commit_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def initialize(file, commit)
@commit = commit
end

def absolute_path
@file.absolute_path
end

def filename
@file.filename
end
Expand Down
16 changes: 12 additions & 4 deletions lib/rubocop/git/pseudo_resource.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module RuboCop
module Git
class PseudoResource
attr_reader :filename, :patch
attr_reader :patch, :pwd, :file_relative_path

def initialize(filename)
@filename = filename
@patch = ''
alias_method :filename, :file_relative_path

def initialize(file_relative_path, pwd = Dir.pwd)
@file_relative_path = file_relative_path
@pwd = pwd
@patch = ''
end

def absolute_path
filename
File.join(pwd, filename)
end

def status
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/git/style_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(modified_files,

def violations
file_violations = @modified_files.map do |modified_file|
FileViolation.new(modified_file.filename, offenses(modified_file))
FileViolation.new(modified_file.absolute_path, offenses(modified_file))
end

file_violations.select do |file_violation|
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/git/style_guide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ def ignored_file?(file)
end

def excluded_file?(file)
config.file_to_exclude?(file.filename)
config.file_to_exclude?(file.absolute_path)
end

def parse_source(file)
rubocop_version = Gem::Version.new(RuboCop::Version::STRING)
if rubocop_version < Gem::Version.new('0.36.0')
RuboCop::ProcessedSource.new(file.content, file.filename)
RuboCop::ProcessedSource.new(file.content, file.absolute_path)
elsif rubocop_version < Gem::Version.new('0.41.0')
RuboCop::ProcessedSource.new(file.content,
target_ruby_version, file.filename)
target_ruby_version, file.absolute_path)
else
RuboCop::ProcessedSource.new(file.content,
config.target_ruby_version, file.filename)
config.target_ruby_version, file.absolute_path)
end
end

Expand Down