Class: RuboCop::Git::CommitFile
- Inherits:
-
Object
- Object
- RuboCop::Git::CommitFile
- Defined in:
- lib/rubocop/git/commit_file.rb
Overview
Instance Method Summary collapse
- #content ⇒ Object
- #filename ⇒ Object
-
#initialize(file, commit) ⇒ CommitFile
constructor
A new instance of CommitFile.
- #modified_line_at(line_number) ⇒ Object
- #modified_lines ⇒ Object
- #relevant_line?(line_number) ⇒ Boolean
- #removed? ⇒ Boolean
- #ruby? ⇒ Boolean
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
#content ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rubocop/git/commit_file.rb', line 13 def content @content ||= begin unless removed? @commit.file_content(filename) end end end |
#filename ⇒ Object
9 10 11 |
# File 'lib/rubocop/git/commit_file.rb', line 9 def filename @file.filename end |
#modified_line_at(line_number) ⇒ Object
39 40 41 42 43 |
# File 'lib/rubocop/git/commit_file.rb', line 39 def modified_line_at(line_number) modified_lines.detect do |modified_line| modified_line.line_number == line_number end end |
#modified_lines ⇒ Object
35 36 37 |
# File 'lib/rubocop/git/commit_file.rb', line 35 def modified_lines @modified_lines ||= patch.additions end |
#relevant_line?(line_number) ⇒ Boolean
21 22 23 24 25 |
# File 'lib/rubocop/git/commit_file.rb', line 21 def relevant_line?(line_number) modified_lines.detect do |modified_line| modified_line.line_number == line_number end end |
#removed? ⇒ Boolean
27 28 29 |
# File 'lib/rubocop/git/commit_file.rb', line 27 def removed? @file.status == 'removed' end |
#ruby? ⇒ Boolean
31 32 33 |
# File 'lib/rubocop/git/commit_file.rb', line 31 def ruby? filename.match(/.*\.rb$/) end |