Class: RuboCop::Gradual::Results::File

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/gradual/results/file.rb

Overview

File is a representation of a file in a Gradual results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, issues:, hash: nil) ⇒ File

Returns a new instance of File.



12
13
14
15
16
17
# File 'lib/rubocop/gradual/results/file.rb', line 12

def initialize(path:, issues:, hash: nil)
  @path = path
  @file_hash = hash || djb2a(data)
  @issues = prepare_issues(issues).sort
  @data = nil
end

Instance Attribute Details

#file_hashObject (readonly)

Returns the value of attribute file_hash.



10
11
12
# File 'lib/rubocop/gradual/results/file.rb', line 10

def file_hash
  @file_hash
end

#issuesObject (readonly)

Returns the value of attribute issues.



10
11
12
# File 'lib/rubocop/gradual/results/file.rb', line 10

def issues
  @issues
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/rubocop/gradual/results/file.rb', line 10

def path
  @path
end

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/rubocop/gradual/results/file.rb', line 10

def state
  @state
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
# File 'lib/rubocop/gradual/results/file.rb', line 19

def <=>(other)
  path <=> other.path
end

#changed_issues(other_file) ⇒ Object



23
24
25
26
27
# File 'lib/rubocop/gradual/results/file.rb', line 23

def changed_issues(other_file)
  issues.reject do |result_issue|
    other_file.issues.find { |other_issue| result_issue == other_issue }
  end
end