Class: RuboCop::Git::CommitFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/git/commit_file.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(file, commit) ⇒ CommitFile

Returns a new instance of CommitFile.



3
4
5
6
# File 'lib/rubocop/git/commit_file.rb', line 3

def initialize(file, commit)
  @file = file
  @commit = commit
end

Instance Method Details

#absolute_pathObject



8
9
10
# File 'lib/rubocop/git/commit_file.rb', line 8

def absolute_path
  @file.absolute_path
end

#contentObject



16
17
18
19
20
# File 'lib/rubocop/git/commit_file.rb', line 16

def content
  @content ||= unless removed?
                 @commit.file_content(filename)
               end
end

#filenameObject



12
13
14
# File 'lib/rubocop/git/commit_file.rb', line 12

def filename
  @file.filename
end

#modified_line_at(line_number) ⇒ Object



34
35
36
# File 'lib/rubocop/git/commit_file.rb', line 34

def modified_line_at(line_number)
  modified_lines[line_number]
end

#modified_linesObject



30
31
32
# File 'lib/rubocop/git/commit_file.rb', line 30

def modified_lines
  @modified_lines ||= patch.changed_lines
end

#relevant_line?(line_number) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rubocop/git/commit_file.rb', line 22

def relevant_line?(line_number)
  !modified_line_at(line_number).nil?
end

#removed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rubocop/git/commit_file.rb', line 26

def removed?
  @file.status == 'removed'
end