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.



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

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

Instance Method Details

#absolute_pathObject



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

def absolute_path
  @file.absolute_path
end

#contentObject



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

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

#filenameObject



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

def filename
  @file.filename
end

#modified_line_at(line_number) ⇒ Object



37
38
39
# File 'lib/rubocop/git/commit_file.rb', line 37

def modified_line_at(line_number)
  modified_lines[line_number]
end

#modified_linesObject



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

def modified_lines
  @modified_lines ||= patch.changed_lines
end

#relevant_line?(line_number) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#removed?Boolean

Returns:

  • (Boolean)


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

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