Class: Policial::Investigation

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/investigation.rb

Overview

Public: Starting with unparsed data coming from a pull request event, it checks all changes introduced looking for style guide violations. It also accuse all present violations through comments on all relevant lines in the pull request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pull_request) ⇒ Investigation

Returns a new instance of Investigation.



9
10
11
# File 'lib/policial/investigation.rb', line 9

def initialize(pull_request)
  @pull_request = pull_request
end

Instance Attribute Details

#pull_requestObject

Returns the value of attribute pull_request.



7
8
9
# File 'lib/policial/investigation.rb', line 7

def pull_request
  @pull_request
end

#violationsObject

Returns the value of attribute violations.



7
8
9
# File 'lib/policial/investigation.rb', line 7

def violations
  @violations
end

Instance Method Details

#accuseObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/policial/investigation.rb', line 17

def accuse
  return if @violations.blank?

  commenter = Commenter.new(@pull_request)

  @violations.each do |violation|
    if accusation_policy.allowed_for?(violation)
      commenter.comment_violation(violation)
    end
  end
end

#runObject



13
14
15
# File 'lib/policial/investigation.rb', line 13

def run
  @violations ||= StyleChecker.new(@pull_request).violations
end