Class: CC::Service::GitHubIssues

Inherits:
CC::Service show all
Defined in:
lib/cc/services/github_issues.rb

Defined Under Namespace

Classes: Config

Constant Summary

Constants inherited from CC::Service

ABSTRACT_SLUGS, ALL_EVENTS, ConfigurationError, Error

Constants included from Helper

Helper::GREEN_HEX, Helper::RED_HEX

Constants included from HTTP

HTTP::REDIRECT_CODES

Instance Attribute Summary

Attributes inherited from CC::Service

#config, #event, #payload

Instance Method Summary collapse

Methods inherited from CC::Service

by_slug, inherited, #initialize, load_services, #receive, services, slug

Methods included from Helper

#changed, #color, #compare_url, #details_url, #emoji, #hex_color, #improved?, #repo_name

Methods included from HTTP

#ca_file, #formatted_post_response, #http, #http_method, #raw_get, #raw_post, #service_get, #service_post, #service_post_with_redirects

Constructor Details

This class inherits a constructor from CC::Service

Instance Method Details

#receive_issueObject



48
49
50
51
52
53
54
# File 'lib/cc/services/github_issues.rb', line 48

def receive_issue
  title = %(Fix "#{issue["check_name"]}" issue in #{constant_name})

  body = [issue["description"], details_url].join("\n\n")

  create_issue(title, body)
end

#receive_qualityObject



35
36
37
# File 'lib/cc/services/github_issues.rb', line 35

def receive_quality
  create_issue(quality_title, details_url)
end

#receive_testObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/cc/services/github_issues.rb', line 24

def receive_test
  result = create_issue("Test ticket from Code Climate", "")
  result.merge(
    message: "Issue <a href='#{result[:url]}'>##{result[:number]}</a> created.",
  )
rescue CC::Service::HTTPError => e
  body = JSON.parse(e.response_body)
  e.user_message = body["message"]
  raise e
end

#receive_vulnerabilityObject



39
40
41
42
43
44
45
46
# File 'lib/cc/services/github_issues.rb', line 39

def receive_vulnerability
  formatter = CC::Formatters::TicketFormatter.new(self)

  create_issue(
    formatter.format_vulnerability_title,
    formatter.format_vulnerability_body,
  )
end