Code Climate services
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
config
lib
spec
.codeclimate.yml
.gitignore
.rspec
.rubocop.yml
.ruby-version
Gemfile
LICENSE.txt
README.md
Rakefile
base_rubocop.yml
circle.yml
codeclimate-services.gemspec
pull_request_test.rb
service_test.rb

README.md

Code Climate Services

Code Climate Test Coverage

A collection of classes, each responsible for integrating one external service with the Code Climate system.

Overview

Services define #receive_<event> methods for any events they are interested in. These methods will be invoked with @payload set to a hash of data about the event being handled.

The structure of this data is described below. Note that there may be additional keys not listed here.

Events

Attributes common to all event types:

{
  "repo_name": String,
  "details_url": String
}

Coverage

Event name: coverage

Event-specific attributes:

{
  "covered_percent": Float,
  "previous_covered_percent": Float,
  "covered_percent_delta": Float,
  "compare_url": String
}

Quality

Event name: quality

Event-specific attributes:

{
  "constant_name": String,
  "rating": String, // "A", "B", "C", etc
  "previous_rating": String,
  "remediation_cost": Float,
  "previous_remediation_cost": Float,
  "compare_url": String
}

Vulnerability

Event name: vulnerability

Event-specific attributes:

{
  "warning_type": String,
  "vulnerabilities": [{
    "warning_type": String,
    "location": String
  }, {
    // ...
  }]
}

Note: The reason for the top-level warning_type attribute is for when the list of vulnerabilities are of mixed warning types. In this case, the top-level attribute can be used in any messaging.

Pull Request

Event name: pull_request

Event-specific attributes:

{
  "state": String, // "pending", or "success"
  "github_slug": String, // user/repo
  "number": String,
  "commit_sha": String,
}

Pull Request Coverage

Event name: pull_request_coverage

Event-specific attributes:

{
  "state": String, // "pending", "success", or "failure"
  "github_slug": String, // user/repo
  "number": String,
  "commit_sha": String,
  "covered_percent_delta": Float,
}

Other Events

The following are not fully implemented yet.

  • snapshot

Contributing

To add a new integration, you'll need to create a new Service subclass. Please use existing services as an example:

Ensure that your class implements #receive_test. It must handle any exceptions and always return a hash of { ok: true|false, message: "String (HTML ok)" }. Example.

When you open your PR, please include an image for your service.

License

See LICENSE.txt. This incorporates code from bugsnag-notification-plugins and github-services, both MIT licensed.