├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ ├── release.yml │ ├── standard.yml │ └── test.yml ├── .gitignore ├── .tool-versions ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── action.yml ├── bin ├── format ├── rspec └── standardrb ├── lib ├── entrypoint.sh ├── github_check_run_service.rb ├── github_client.rb ├── index.rb └── report_adapter.rb ├── screenshots ├── check-overview.png ├── file-annotation.png └── standardrb-action.png ├── spec ├── fixtures │ └── report.json ├── github_check_run_service_spec.rb ├── report_adapter_spec.rb └── spec_helper.rb └── version.txt /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: andrewmcodes 7 | 8 | --- 9 | 10 | # Bug Report 11 | 12 | ## Describe the bug 13 | 14 | A clear and concise description of what the bug is. 15 | 16 | # To Reproduce 17 | 18 | Steps to reproduce the behavior: 19 | 20 | # Expected behavior 21 | 22 | A clear and concise description of what you expected to happen. 23 | 24 | ## Stacktrace 25 | 26 | If applicable, add the action stacktrace. 27 | 28 | ## Action Version & Workflow File 29 | 30 | - Version [e.g. v0.0.1] 31 | 32 | ### Workflow File 33 | 34 | ```yaml 35 | # my workflow 36 | ``` 37 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Type of PR (feature, enhancement, bug fix, etc.) 2 | 3 | ## Description 4 | 5 | Please include a summary of the change and which issue is fixed. 6 | 7 | Fixes # (issue) 8 | 9 | ## Why should this be added 10 | 11 | Explain value. 12 | 13 | ## Checklist 14 | 15 | - [ ] My code follows the style guidelines of this project 16 | - [ ] Actions are passing 17 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | name: Action CI 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Verify action syntax 12 | # The action should not publish any real changes, but should succeed. 13 | uses: './' 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | - master 6 | 7 | name: release 8 | jobs: 9 | release-please: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: google-github-actions/release-please-action@v3 13 | with: 14 | release-type: simple 15 | package-name: andrewmcodes/standardrb-action 16 | -------------------------------------------------------------------------------- /.github/workflows/standard.yml: -------------------------------------------------------------------------------- 1 | name: StandardRB 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: ["main"] 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: andrewmcodes/actions/setup-ruby@main 18 | - name: 🔍 Standard 19 | uses: andrewmcodes/actions/standard@main -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: ["main"] 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} 11 | 12 | jobs: 13 | test: 14 | name: Rspec Test Action 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: andrewmcodes/actions/setup-ruby@main 19 | - name: Run Rspec 20 | run: bin/rspec 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tmp/ 2 | /.vscode/ 3 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | ruby 3.3.0 -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [2.0.0](https://github.com/andrewmcodes/standardrb-action/compare/v1.0.0...v2.0.0) (2024-04-09) 4 | 5 | 6 | ### ⚠ BREAKING CHANGES 7 | 8 | * upgrade Ruby version to 3.2.2 ([#20](https://github.com/andrewmcodes/standardrb-action/issues/20)) 9 | 10 | ### Features 11 | 12 | * upgrade Ruby version to 3.2.2 ([#20](https://github.com/andrewmcodes/standardrb-action/issues/20)) ([ccdbc2a](https://github.com/andrewmcodes/standardrb-action/commit/ccdbc2a4ff192bf4c2ead28b0851780519469812)) 13 | 14 | ## [1.0.0](https://github.com/andrewmcodes/standardrb-action/compare/v0.0.2...v1.0.0) (2022-04-23) 15 | 16 | 17 | ### ⚠ BREAKING CHANGES 18 | 19 | * **dev-deps:** upgrade Standard to 1.10 (#15) 20 | 21 | ### Features 22 | 23 | * **dev-deps:** upgrade Standard to 1.10 ([#15](https://github.com/andrewmcodes/standardrb-action/issues/15)) ([2f91b2e](https://github.com/andrewmcodes/standardrb-action/commit/2f91b2e70518d724dca228d9910978abf0ec120e)) 24 | 25 | 26 | ### Bug Fixes 27 | 28 | * address all failing lints ([#17](https://github.com/andrewmcodes/standardrb-action/issues/17)) ([7334a82](https://github.com/andrewmcodes/standardrb-action/commit/7334a82973d088fdde2904d7c4cd2dc88629c1a4)) 29 | 30 | ## [Unreleased](https://github.com/andrewmcodes/standardrb-action/tree/HEAD) 31 | 32 | [Full Changelog](https://github.com/andrewmcodes/standardrb-action/compare/v0.0.2...HEAD) 33 | 34 | **Merged pull requests:** 35 | 36 | - Update incorrect project name in README [\#8](https://github.com/andrewmcodes/standardrb-action/pull/8) ([martinemde](https://github.com/martinemde)) 37 | - Add changelog generator [\#6](https://github.com/andrewmcodes/standardrb-action/pull/6) ([andrewmcodes](https://github.com/andrewmcodes)) 38 | 39 | ## [v0.0.2](https://github.com/andrewmcodes/standardrb-action/tree/v0.0.2) (2019-11-07) 40 | 41 | [Full Changelog](https://github.com/andrewmcodes/standardrb-action/compare/v0.0.1...v0.0.2) 42 | 43 | **Merged pull requests:** 44 | 45 | - v0.0.2 version bump [\#4](https://github.com/andrewmcodes/standardrb-action/pull/4) ([andrewmcodes](https://github.com/andrewmcodes)) 46 | - Fix unprocessable entity error when versions are present [\#3](https://github.com/andrewmcodes/standardrb-action/pull/3) ([andrewmcodes](https://github.com/andrewmcodes)) 47 | - docs: add andrewmcodes as a contributor [\#2](https://github.com/andrewmcodes/standardrb-action/pull/2) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 48 | - Update issue templates [\#1](https://github.com/andrewmcodes/standardrb-action/pull/1) ([andrewmcodes](https://github.com/andrewmcodes)) 49 | 50 | ## [v0.0.1](https://github.com/andrewmcodes/standardrb-action/tree/v0.0.1) (2019-11-07) 51 | 52 | [Full Changelog](https://github.com/andrewmcodes/standardrb-action/compare/1c89e16f1ed4ca0d42fbc84b93f925f6a8d83da9...v0.0.1) 53 | 54 | 55 | 56 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 57 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at support@andrewm.codes. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | [code-of-conduct]: CODE_OF_CONDUCT.md 4 | 5 | Hey, there! 👋 Any and all contributions are welcome. 6 | 7 | Please make sure to read the [code of conduct][code-of-conduct] before submitting issues or pull requests. 8 | 9 | To lend a helping hand: 10 | 11 | * [Fork the repository](https://help.github.com/articles/fork-a-repo/) 12 | * Make your desired changes 13 | * [Create a pull request](https://help.github.com/articles/creating-a-pull-request/) 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:alpine3.18 2 | 3 | RUN apk add --update build-base git 4 | 5 | COPY lib /action/lib 6 | COPY README.md LICENSE / 7 | 8 | RUN gem install bundler 9 | 10 | ENTRYPOINT ["/action/lib/entrypoint.sh"] 11 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | group :development do 6 | gem "standard", "< 2.0" 7 | end 8 | 9 | group :test do 10 | gem "json", "~> 2.6.1" 11 | gem "rspec", "~> 3.11.0" 12 | gem "webmock", "~> 3.14" 13 | end 14 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.8.0) 5 | public_suffix (>= 2.0.2, < 5.0) 6 | ast (2.4.2) 7 | crack (0.4.5) 8 | rexml 9 | diff-lcs (1.5.0) 10 | hashdiff (1.0.1) 11 | json (2.6.1) 12 | language_server-protocol (3.17.0.3) 13 | lint_roller (1.1.0) 14 | parallel (1.24.0) 15 | parser (3.3.0.5) 16 | ast (~> 2.4.1) 17 | racc 18 | public_suffix (4.0.7) 19 | racc (1.7.3) 20 | rainbow (3.1.1) 21 | regexp_parser (2.9.0) 22 | rexml (3.2.6) 23 | rspec (3.11.0) 24 | rspec-core (~> 3.11.0) 25 | rspec-expectations (~> 3.11.0) 26 | rspec-mocks (~> 3.11.0) 27 | rspec-core (3.11.0) 28 | rspec-support (~> 3.11.0) 29 | rspec-expectations (3.11.0) 30 | diff-lcs (>= 1.2.0, < 2.0) 31 | rspec-support (~> 3.11.0) 32 | rspec-mocks (3.11.1) 33 | diff-lcs (>= 1.2.0, < 2.0) 34 | rspec-support (~> 3.11.0) 35 | rspec-support (3.11.0) 36 | rubocop (1.62.1) 37 | json (~> 2.3) 38 | language_server-protocol (>= 3.17.0) 39 | parallel (~> 1.10) 40 | parser (>= 3.3.0.2) 41 | rainbow (>= 2.2.2, < 4.0) 42 | regexp_parser (>= 1.8, < 3.0) 43 | rexml (>= 3.2.5, < 4.0) 44 | rubocop-ast (>= 1.31.1, < 2.0) 45 | ruby-progressbar (~> 1.7) 46 | unicode-display_width (>= 2.4.0, < 3.0) 47 | rubocop-ast (1.31.2) 48 | parser (>= 3.3.0.4) 49 | rubocop-performance (1.20.2) 50 | rubocop (>= 1.48.1, < 2.0) 51 | rubocop-ast (>= 1.30.0, < 2.0) 52 | ruby-progressbar (1.13.0) 53 | standard (1.35.1) 54 | language_server-protocol (~> 3.17.0.2) 55 | lint_roller (~> 1.0) 56 | rubocop (~> 1.62.0) 57 | standard-custom (~> 1.0.0) 58 | standard-performance (~> 1.3) 59 | standard-custom (1.0.2) 60 | lint_roller (~> 1.0) 61 | rubocop (~> 1.50) 62 | standard-performance (1.3.1) 63 | lint_roller (~> 1.1) 64 | rubocop-performance (~> 1.20.2) 65 | unicode-display_width (2.5.0) 66 | webmock (3.14.0) 67 | addressable (>= 2.8.0) 68 | crack (>= 0.3.2) 69 | hashdiff (>= 0.4.0, < 2.0.0) 70 | 71 | PLATFORMS 72 | ruby 73 | 74 | DEPENDENCIES 75 | json (~> 2.6.1) 76 | rspec (~> 3.11.0) 77 | standard (< 2.0) 78 | webmock (~> 3.14) 79 | 80 | BUNDLED WITH 81 | 2.2.33 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2022 Andrew Mason 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!CAUTION] 2 | > This action is no longer maintained. Instead, consider this fork that is maintained by the Standard Ruby team at [standardrb/standard-ruby-action](https://github.com/standardrb/standard-ruby-action) 3 | 4 | 5 | # :white_check_mark: StandardRB Action 6 | 7 | A GitHub Action to run [StandardRB](https://github.com/testdouble/standard) against your code and create annotations in the GitHub UI. 8 | 9 | ## :page_facing_up: Introduction 10 | 11 | GitHub Actions are an amazing new tool that can dramatically improve productivity while using the GitHub platform. While it is not hard to write a custom GitHub action to run StandardRB on your codebase, this action takes that functionality one step further using the checks API. After the StandardRB Linter Action runs StandardRB against your code, it will create annotations that you can easily view, matched up with the offending code. 12 | 13 | ## :bulb: Usage 14 | 15 | Add the following to your GitHub action workflow to use StandardRB Linter Action: 16 | 17 | ```yaml 18 | - name: StandardRB Linter 19 | uses: andrewmcodes/standardrb-action@v2.0.0 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | ``` 23 | 24 | ### :package: Example Workflow 25 | 26 | Here is an example workflow file incorporating StandardRB Linter Action: 27 | 28 | ```yaml 29 | name: StandardRB 30 | 31 | on: [push] 32 | 33 | jobs: 34 | build: 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v4 38 | - name: StandardRB Linter 39 | uses: andrewmcodes/standardrb-action@v2.0.0 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | ``` 43 | 44 | ## :warning: Gotchas 45 | 46 | Due to the GitHub Check Runs API, we can only return 50 annotations per run. See [here](https://developer.github.com/v3/checks/runs/#output-object) for more info. 47 | 48 | This is not an issue if you remove this action from your workflow and replace with `bundle exec standardrb --format github --parallel` as mentioned in the caution above. 49 | 50 | ## :camera_flash: Screenshots 51 | 52 | ![StandardRB Action Checks Overview](screenshots/check-overview.png) 53 | ![StandardRB Action File Annotation](screenshots/file-annotation.png) 54 | 55 | ## :bookmark: Changelog 56 | 57 | [View our Changelog](/CHANGELOG.md) 58 | 59 | ## :sos: Contributing 60 | 61 | [Contributing Guide](/CONTRIBUTING.md) 62 | 63 | ## :rotating_light: Code of Conduct 64 | 65 | [Code of Conduct](/CODE_OF_CONDUCT.md) 66 | 67 | ## :copyright: License 68 | 69 | [MIT](/LICENSE.md) 70 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | 2 | name: 'StandardRB Action' 3 | description: 'A GitHub Action that lints your Ruby code with StandardRB!' 4 | author: 'Andrew Mason ' 5 | runs: 6 | using: 'docker' 7 | image: 'Dockerfile' 8 | env: 9 | GITHUB_TOKEN: secrets.GITHUB_TOKEN 10 | branding: 11 | icon: 'code' 12 | color: 'gray-dark' 13 | -------------------------------------------------------------------------------- /bin/format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin/standardrb --fix -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'rspec' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 23 | end 24 | end 25 | 26 | require 'rubygems' 27 | require 'bundler/setup' 28 | 29 | load Gem.bin_path('rspec-core', 'rspec') 30 | -------------------------------------------------------------------------------- /bin/standardrb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'standardrb' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "pathname" 12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path("../bundle", __FILE__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 23 | end 24 | end 25 | 26 | require "rubygems" 27 | require "bundler/setup" 28 | 29 | load Gem.bin_path("standard", "standardrb") 30 | -------------------------------------------------------------------------------- /lib/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | gem install standard 6 | 7 | ruby /action/lib/index.rb 8 | -------------------------------------------------------------------------------- /lib/github_check_run_service.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class GithubCheckRunService 4 | CHECK_NAME = "StandardRB" 5 | 6 | def initialize(report, github_data, report_adapter) 7 | @report = report 8 | @github_data = github_data 9 | @report_adapter = report_adapter 10 | @client = GithubClient.new(@github_data[:token], user_agent: "standardrb-action") 11 | end 12 | 13 | def run 14 | id = @client.post( 15 | endpoint_url, 16 | create_check_payload 17 | )["id"] 18 | @summary = @report_adapter.summary(@report) 19 | @annotations = @report_adapter.annotations(@report) 20 | @conclusion = @report_adapter.conclusion(@report) 21 | 22 | @client.patch( 23 | "#{endpoint_url}/#{id}", 24 | update_check_payload 25 | ) 26 | end 27 | 28 | private 29 | 30 | def endpoint_url 31 | "/repos/#{@github_data[:owner]}/#{@github_data[:repo]}/check-runs" 32 | end 33 | 34 | def base_payload(status) 35 | { 36 | name: CHECK_NAME, 37 | head_sha: @github_data[:sha], 38 | status: status, 39 | started_at: Time.now.iso8601 40 | } 41 | end 42 | 43 | def create_check_payload 44 | base_payload("in_progress") 45 | end 46 | 47 | def update_check_payload 48 | base_payload("completed").merge!( 49 | conclusion: @conclusion, 50 | output: { 51 | title: CHECK_NAME, 52 | summary: @summary, 53 | annotations: @annotations 54 | } 55 | ) 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/github_client.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class GithubClient 4 | def initialize(github_token, user_agent: "ruby") 5 | @github_token = github_token 6 | @user_agent = user_agent 7 | end 8 | 9 | def patch(url, body = {}) 10 | request_http do |http| 11 | http.patch(url, body.to_json, headers) 12 | end 13 | end 14 | 15 | def post(url, body = {}) 16 | request_http do |http| 17 | http.post(url, body.to_json, headers) 18 | end 19 | end 20 | 21 | private 22 | 23 | def headers 24 | @headers ||= { 25 | "Content-Type": "application/json", 26 | Accept: "application/vnd.github.antiope-preview+json", 27 | Authorization: "Bearer #{@github_token}", 28 | "User-Agent": @user_agent 29 | } 30 | end 31 | 32 | def request_http 33 | http = Net::HTTP.new("api.github.com", 443) 34 | http.use_ssl = true 35 | response = yield(http) 36 | raise "#{response.message}: #{response.body}" if response.code.to_i >= 300 37 | 38 | JSON.parse(response.body) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/index.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "net/http" 4 | require "json" 5 | require "time" 6 | require_relative "report_adapter" 7 | require_relative "github_check_run_service" 8 | require_relative "github_client" 9 | 10 | def read_json(path) 11 | JSON.parse(File.read(path)) 12 | end 13 | 14 | @event_json = read_json(ENV["GITHUB_EVENT_PATH"]) if ENV["GITHUB_EVENT_PATH"] 15 | @github_data = { 16 | sha: ENV["GITHUB_SHA"], 17 | token: ENV["GITHUB_TOKEN"], 18 | owner: ENV["GITHUB_REPOSITORY_OWNER"] || @event_json.dig("repository", "owner", "login"), 19 | repo: ENV["GITHUB_REPOSITORY_NAME"] || @event_json.dig("repository", "name") 20 | } 21 | @report = 22 | if ENV["REPORT_PATH"] 23 | read_json(ENV["REPORT_PATH"]) 24 | else 25 | Dir.chdir(ENV["GITHUB_WORKSPACE"]) { JSON.parse(`standardrb --parallel -f json`) } 26 | end 27 | 28 | GithubCheckRunService.new(@report, @github_data, ReportAdapter).run 29 | -------------------------------------------------------------------------------- /lib/report_adapter.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ReportAdapter 4 | class << self 5 | CONCLUSION_TYPES = {failure: "failure", success: "success"}.freeze 6 | ANNOTATION_LEVELS = { 7 | "refactor" => "failure", 8 | "convention" => "failure", 9 | "warning" => "warning", 10 | "error" => "failure", 11 | "fatal" => "failure" 12 | }.freeze 13 | 14 | def conclusion(report) 15 | return CONCLUSION_TYPES[:failure] if total_offenses(report).positive? 16 | 17 | CONCLUSION_TYPES[:success] 18 | end 19 | 20 | def summary(report) 21 | "#{total_offenses(report)} offense(s) found" 22 | end 23 | 24 | def annotations(report) 25 | annotation_list = [] 26 | count = 0 27 | report["files"].each do |file| 28 | file["offenses"].each do |offense| 29 | count += 1 30 | return annotation_list if count == 48 31 | 32 | location = offense["location"] 33 | same_line = location["start_line"] == location["last_line"] 34 | annotation_list.push( 35 | { 36 | path: file["path"], 37 | start_line: location["start_line"], 38 | end_line: location["last_line"], 39 | start_column: (location["start_column"] if same_line), 40 | end_column: (location["last_column"] if same_line), 41 | annotation_level: annotation_level(offense["severity"]), 42 | message: offense["message"] 43 | }.compact.transform_keys!(&:to_s) 44 | ) 45 | end 46 | end 47 | annotation_list 48 | end 49 | 50 | private 51 | 52 | def annotation_level(severity) 53 | ANNOTATION_LEVELS[severity] 54 | end 55 | 56 | def total_offenses(report) 57 | report.dig("summary", "offense_count") 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /screenshots/check-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewmcodes/standardrb-action/e94563db78d4e87410f0b1d3418260b3a61ec48e/screenshots/check-overview.png -------------------------------------------------------------------------------- /screenshots/file-annotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewmcodes/standardrb-action/e94563db78d4e87410f0b1d3418260b3a61ec48e/screenshots/file-annotation.png -------------------------------------------------------------------------------- /screenshots/standardrb-action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewmcodes/standardrb-action/e94563db78d4e87410f0b1d3418260b3a61ec48e/screenshots/standardrb-action.png -------------------------------------------------------------------------------- /spec/fixtures/report.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "rubocop_version": "0.75.1", 4 | "ruby_engine": "ruby", 5 | "ruby_version": "2.6.4", 6 | "ruby_patchlevel": "104", 7 | "ruby_platform": "x86_64-darwin18" 8 | }, 9 | "files": [ 10 | { 11 | "path": "Gemfile", 12 | "offenses": [ 13 | { 14 | "severity": "convention", 15 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 16 | "cop_name": "Style/StringLiterals", 17 | "corrected": false, 18 | "location": { 19 | "start_line": 3, 20 | "start_column": 8, 21 | "last_line": 3, 22 | "last_column": 29, 23 | "length": 22, 24 | "line": 3, 25 | "column": 8 26 | } 27 | }, 28 | { 29 | "severity": "convention", 30 | "message": "Put a comma after the last item of a multiline hash.", 31 | "cop_name": "Style/TrailingCommaInHashLiteral", 32 | "corrected": false, 33 | "location": { 34 | "start_line": 39, 35 | "start_column": 7, 36 | "last_line": 40, 37 | "last_column": 34, 38 | "length": 28, 39 | "line": 39, 40 | "column": 7 41 | } 42 | }, 43 | { 44 | "severity": "convention", 45 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 46 | "cop_name": "Style/StringLiterals", 47 | "corrected": false, 48 | "location": { 49 | "start_line": 44, 50 | "start_column": 18, 51 | "last_line": 44, 52 | "last_column": 30, 53 | "length": 13, 54 | "line": 44, 55 | "column": 18 56 | } 57 | }, 58 | { 59 | "severity": "convention", 60 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 61 | "cop_name": "Style/StringLiterals", 62 | "corrected": false, 63 | "location": { 64 | "start_line": 48, 65 | "start_column": 18, 66 | "last_line": 48, 67 | "last_column": 28, 68 | "length": 11, 69 | "line": 48, 70 | "column": 18 71 | } 72 | }, 73 | { 74 | "severity": "convention", 75 | "message": "Put a comma after the last item of a multiline hash.", 76 | "cop_name": "Style/TrailingCommaInHashLiteral", 77 | "corrected": false, 78 | "location": { 79 | "start_line": 53, 80 | "start_column": 9, 81 | "last_line": 53, 82 | "last_column": 63, 83 | "length": 55, 84 | "line": 53, 85 | "column": 9 86 | } 87 | }, 88 | { 89 | "severity": "convention", 90 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 91 | "cop_name": "Style/StringLiterals", 92 | "corrected": false, 93 | "location": { 94 | "start_line": 53, 95 | "start_column": 54, 96 | "last_line": 53, 97 | "last_column": 62, 98 | "length": 9, 99 | "line": 53, 100 | "column": 54 101 | } 102 | } 103 | ] 104 | }, 105 | { 106 | "path": "lib/github_client.rb", 107 | "offenses": [ 108 | { 109 | "severity": "convention", 110 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 111 | "cop_name": "Style/StringLiterals", 112 | "corrected": false, 113 | "location": { 114 | "start_line": 4, 115 | "start_column": 44, 116 | "last_line": 4, 117 | "last_column": 49, 118 | "length": 6, 119 | "line": 4, 120 | "column": 44 121 | } 122 | }, 123 | { 124 | "severity": "convention", 125 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 126 | "cop_name": "Style/StringLiterals", 127 | "corrected": false, 128 | "location": { 129 | "start_line": 25, 130 | "start_column": 23, 131 | "last_line": 25, 132 | "last_column": 40, 133 | "length": 18, 134 | "line": 25, 135 | "column": 23 136 | } 137 | }, 138 | { 139 | "severity": "convention", 140 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 141 | "cop_name": "Style/StringLiterals", 142 | "corrected": false, 143 | "location": { 144 | "start_line": 26, 145 | "start_column": 17, 146 | "last_line": 26, 147 | "last_column": 61, 148 | "length": 45, 149 | "line": 26, 150 | "column": 17 151 | } 152 | }, 153 | { 154 | "severity": "convention", 155 | "message": "Put a comma after the last item of a multiline hash.", 156 | "cop_name": "Style/TrailingCommaInHashLiteral", 157 | "corrected": false, 158 | "location": { 159 | "start_line": 28, 160 | "start_column": 7, 161 | "last_line": 28, 162 | "last_column": 31, 163 | "length": 25, 164 | "line": 28, 165 | "column": 7 166 | } 167 | }, 168 | { 169 | "severity": "convention", 170 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 171 | "cop_name": "Style/StringLiterals", 172 | "corrected": false, 173 | "location": { 174 | "start_line": 33, 175 | "start_column": 26, 176 | "last_line": 33, 177 | "last_column": 41, 178 | "length": 16, 179 | "line": 33, 180 | "column": 26 181 | } 182 | } 183 | ] 184 | }, 185 | { 186 | "path": "lib/index.rb", 187 | "offenses": [ 188 | { 189 | "severity": "convention", 190 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 191 | "cop_name": "Style/StringLiterals", 192 | "corrected": false, 193 | "location": { 194 | "start_line": 3, 195 | "start_column": 9, 196 | "last_line": 3, 197 | "last_column": 18, 198 | "length": 10, 199 | "line": 3, 200 | "column": 9 201 | } 202 | }, 203 | { 204 | "severity": "convention", 205 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 206 | "cop_name": "Style/StringLiterals", 207 | "corrected": false, 208 | "location": { 209 | "start_line": 4, 210 | "start_column": 9, 211 | "last_line": 4, 212 | "last_column": 14, 213 | "length": 6, 214 | "line": 4, 215 | "column": 9 216 | } 217 | }, 218 | { 219 | "severity": "convention", 220 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 221 | "cop_name": "Style/StringLiterals", 222 | "corrected": false, 223 | "location": { 224 | "start_line": 5, 225 | "start_column": 9, 226 | "last_line": 5, 227 | "last_column": 14, 228 | "length": 6, 229 | "line": 5, 230 | "column": 9 231 | } 232 | }, 233 | { 234 | "severity": "convention", 235 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 236 | "cop_name": "Style/StringLiterals", 237 | "corrected": false, 238 | "location": { 239 | "start_line": 6, 240 | "start_column": 18, 241 | "last_line": 6, 242 | "last_column": 35, 243 | "length": 18, 244 | "line": 6, 245 | "column": 18 246 | } 247 | }, 248 | { 249 | "severity": "convention", 250 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 251 | "cop_name": "Style/StringLiterals", 252 | "corrected": false, 253 | "location": { 254 | "start_line": 7, 255 | "start_column": 18, 256 | "last_line": 7, 257 | "last_column": 45, 258 | "length": 28, 259 | "line": 7, 260 | "column": 18 261 | } 262 | }, 263 | { 264 | "severity": "convention", 265 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 266 | "cop_name": "Style/StringLiterals", 267 | "corrected": false, 268 | "location": { 269 | "start_line": 8, 270 | "start_column": 18, 271 | "last_line": 8, 272 | "last_column": 34, 273 | "length": 17, 274 | "line": 8, 275 | "column": 18 276 | } 277 | }, 278 | { 279 | "severity": "convention", 280 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 281 | "cop_name": "Style/StringLiterals", 282 | "corrected": false, 283 | "location": { 284 | "start_line": 14, 285 | "start_column": 29, 286 | "last_line": 14, 287 | "last_column": 47, 288 | "length": 19, 289 | "line": 14, 290 | "column": 29 291 | } 292 | }, 293 | { 294 | "severity": "convention", 295 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 296 | "cop_name": "Style/StringLiterals", 297 | "corrected": false, 298 | "location": { 299 | "start_line": 14, 300 | "start_column": 58, 301 | "last_line": 14, 302 | "last_column": 76, 303 | "length": 19, 304 | "line": 14, 305 | "column": 58 306 | } 307 | }, 308 | { 309 | "severity": "convention", 310 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 311 | "cop_name": "Style/StringLiterals", 312 | "corrected": false, 313 | "location": { 314 | "start_line": 16, 315 | "start_column": 12, 316 | "last_line": 16, 317 | "last_column": 23, 318 | "length": 12, 319 | "line": 16, 320 | "column": 12 321 | } 322 | }, 323 | { 324 | "severity": "convention", 325 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 326 | "cop_name": "Style/StringLiterals", 327 | "corrected": false, 328 | "location": { 329 | "start_line": 17, 330 | "start_column": 14, 331 | "last_line": 17, 332 | "last_column": 27, 333 | "length": 14, 334 | "line": 17, 335 | "column": 14 336 | } 337 | }, 338 | { 339 | "severity": "convention", 340 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 341 | "cop_name": "Style/StringLiterals", 342 | "corrected": false, 343 | "location": { 344 | "start_line": 18, 345 | "start_column": 14, 346 | "last_line": 18, 347 | "last_column": 38, 348 | "length": 25, 349 | "line": 18, 350 | "column": 14 351 | } 352 | }, 353 | { 354 | "severity": "convention", 355 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 356 | "cop_name": "Style/StringLiterals", 357 | "corrected": false, 358 | "location": { 359 | "start_line": 18, 360 | "start_column": 60, 361 | "last_line": 18, 362 | "last_column": 71, 363 | "length": 12, 364 | "line": 18, 365 | "column": 60 366 | } 367 | }, 368 | { 369 | "severity": "convention", 370 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 371 | "cop_name": "Style/StringLiterals", 372 | "corrected": false, 373 | "location": { 374 | "start_line": 18, 375 | "start_column": 74, 376 | "last_line": 18, 377 | "last_column": 80, 378 | "length": 7, 379 | "line": 18, 380 | "column": 74 381 | } 382 | }, 383 | { 384 | "severity": "convention", 385 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 386 | "cop_name": "Style/StringLiterals", 387 | "corrected": false, 388 | "location": { 389 | "start_line": 18, 390 | "start_column": 83, 391 | "last_line": 18, 392 | "last_column": 89, 393 | "length": 7, 394 | "line": 18, 395 | "column": 83 396 | } 397 | }, 398 | { 399 | "severity": "convention", 400 | "message": "Put a comma after the last item of a multiline hash.", 401 | "cop_name": "Style/TrailingCommaInHashLiteral", 402 | "corrected": false, 403 | "location": { 404 | "start_line": 19, 405 | "start_column": 3, 406 | "last_line": 19, 407 | "last_column": 78, 408 | "length": 76, 409 | "line": 19, 410 | "column": 3 411 | } 412 | }, 413 | { 414 | "severity": "convention", 415 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 416 | "cop_name": "Style/StringLiterals", 417 | "corrected": false, 418 | "location": { 419 | "start_line": 19, 420 | "start_column": 13, 421 | "last_line": 19, 422 | "last_column": 36, 423 | "length": 24, 424 | "line": 19, 425 | "column": 13 426 | } 427 | }, 428 | { 429 | "severity": "convention", 430 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 431 | "cop_name": "Style/StringLiterals", 432 | "corrected": false, 433 | "location": { 434 | "start_line": 19, 435 | "start_column": 58, 436 | "last_line": 19, 437 | "last_column": 69, 438 | "length": 12, 439 | "line": 19, 440 | "column": 58 441 | } 442 | }, 443 | { 444 | "severity": "convention", 445 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 446 | "cop_name": "Style/StringLiterals", 447 | "corrected": false, 448 | "location": { 449 | "start_line": 19, 450 | "start_column": 72, 451 | "last_line": 19, 452 | "last_column": 77, 453 | "length": 6, 454 | "line": 19, 455 | "column": 72 456 | } 457 | }, 458 | { 459 | "severity": "convention", 460 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 461 | "cop_name": "Style/StringLiterals", 462 | "corrected": false, 463 | "location": { 464 | "start_line": 22, 465 | "start_column": 10, 466 | "last_line": 22, 467 | "last_column": 22, 468 | "length": 13, 469 | "line": 22, 470 | "column": 10 471 | } 472 | }, 473 | { 474 | "severity": "convention", 475 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 476 | "cop_name": "Style/StringLiterals", 477 | "corrected": false, 478 | "location": { 479 | "start_line": 23, 480 | "start_column": 19, 481 | "last_line": 23, 482 | "last_column": 31, 483 | "length": 13, 484 | "line": 23, 485 | "column": 19 486 | } 487 | }, 488 | { 489 | "severity": "convention", 490 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 491 | "cop_name": "Style/StringLiterals", 492 | "corrected": false, 493 | "location": { 494 | "start_line": 25, 495 | "start_column": 19, 496 | "last_line": 25, 497 | "last_column": 36, 498 | "length": 18, 499 | "line": 25, 500 | "column": 19 501 | } 502 | } 503 | ] 504 | }, 505 | { 506 | "path": "lib/report_adapter.rb", 507 | "offenses": [ 508 | { 509 | "severity": "convention", 510 | "message": "Space inside { detected.", 511 | "cop_name": "Layout/SpaceInsideHashLiteralBraces", 512 | "corrected": false, 513 | "location": { 514 | "start_line": 5, 515 | "start_column": 25, 516 | "last_line": 5, 517 | "last_column": 25, 518 | "length": 1, 519 | "line": 5, 520 | "column": 25 521 | } 522 | }, 523 | { 524 | "severity": "convention", 525 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 526 | "cop_name": "Style/StringLiterals", 527 | "corrected": false, 528 | "location": { 529 | "start_line": 5, 530 | "start_column": 35, 531 | "last_line": 5, 532 | "last_column": 43, 533 | "length": 9, 534 | "line": 5, 535 | "column": 35 536 | } 537 | }, 538 | { 539 | "severity": "convention", 540 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 541 | "cop_name": "Style/StringLiterals", 542 | "corrected": false, 543 | "location": { 544 | "start_line": 5, 545 | "start_column": 55, 546 | "last_line": 5, 547 | "last_column": 63, 548 | "length": 9, 549 | "line": 5, 550 | "column": 55 551 | } 552 | }, 553 | { 554 | "severity": "convention", 555 | "message": "Space inside } detected.", 556 | "cop_name": "Layout/SpaceInsideHashLiteralBraces", 557 | "corrected": false, 558 | "location": { 559 | "start_line": 5, 560 | "start_column": 64, 561 | "last_line": 5, 562 | "last_column": 64, 563 | "length": 1, 564 | "line": 5, 565 | "column": 64 566 | } 567 | }, 568 | { 569 | "severity": "convention", 570 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 571 | "cop_name": "Style/StringLiterals", 572 | "corrected": false, 573 | "location": { 574 | "start_line": 7, 575 | "start_column": 7, 576 | "last_line": 7, 577 | "last_column": 16, 578 | "length": 10, 579 | "line": 7, 580 | "column": 7 581 | } 582 | }, 583 | { 584 | "severity": "convention", 585 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 586 | "cop_name": "Style/StringLiterals", 587 | "corrected": false, 588 | "location": { 589 | "start_line": 7, 590 | "start_column": 21, 591 | "last_line": 7, 592 | "last_column": 29, 593 | "length": 9, 594 | "line": 7, 595 | "column": 21 596 | } 597 | }, 598 | { 599 | "severity": "convention", 600 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 601 | "cop_name": "Style/StringLiterals", 602 | "corrected": false, 603 | "location": { 604 | "start_line": 8, 605 | "start_column": 7, 606 | "last_line": 8, 607 | "last_column": 18, 608 | "length": 12, 609 | "line": 8, 610 | "column": 7 611 | } 612 | }, 613 | { 614 | "severity": "convention", 615 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 616 | "cop_name": "Style/StringLiterals", 617 | "corrected": false, 618 | "location": { 619 | "start_line": 8, 620 | "start_column": 23, 621 | "last_line": 8, 622 | "last_column": 31, 623 | "length": 9, 624 | "line": 8, 625 | "column": 23 626 | } 627 | }, 628 | { 629 | "severity": "convention", 630 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 631 | "cop_name": "Style/StringLiterals", 632 | "corrected": false, 633 | "location": { 634 | "start_line": 9, 635 | "start_column": 7, 636 | "last_line": 9, 637 | "last_column": 15, 638 | "length": 9, 639 | "line": 9, 640 | "column": 7 641 | } 642 | }, 643 | { 644 | "severity": "convention", 645 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 646 | "cop_name": "Style/StringLiterals", 647 | "corrected": false, 648 | "location": { 649 | "start_line": 9, 650 | "start_column": 20, 651 | "last_line": 9, 652 | "last_column": 28, 653 | "length": 9, 654 | "line": 9, 655 | "column": 20 656 | } 657 | }, 658 | { 659 | "severity": "convention", 660 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 661 | "cop_name": "Style/StringLiterals", 662 | "corrected": false, 663 | "location": { 664 | "start_line": 10, 665 | "start_column": 7, 666 | "last_line": 10, 667 | "last_column": 13, 668 | "length": 7, 669 | "line": 10, 670 | "column": 7 671 | } 672 | }, 673 | { 674 | "severity": "convention", 675 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 676 | "cop_name": "Style/StringLiterals", 677 | "corrected": false, 678 | "location": { 679 | "start_line": 10, 680 | "start_column": 18, 681 | "last_line": 10, 682 | "last_column": 26, 683 | "length": 9, 684 | "line": 10, 685 | "column": 18 686 | } 687 | }, 688 | { 689 | "severity": "convention", 690 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 691 | "cop_name": "Style/StringLiterals", 692 | "corrected": false, 693 | "location": { 694 | "start_line": 11, 695 | "start_column": 7, 696 | "last_line": 11, 697 | "last_column": 13, 698 | "length": 7, 699 | "line": 11, 700 | "column": 7 701 | } 702 | }, 703 | { 704 | "severity": "convention", 705 | "message": "Put a comma after the last item of a multiline hash.", 706 | "cop_name": "Style/TrailingCommaInHashLiteral", 707 | "corrected": false, 708 | "location": { 709 | "start_line": 11, 710 | "start_column": 7, 711 | "last_line": 11, 712 | "last_column": 26, 713 | "length": 20, 714 | "line": 11, 715 | "column": 7 716 | } 717 | }, 718 | { 719 | "severity": "convention", 720 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 721 | "cop_name": "Style/StringLiterals", 722 | "corrected": false, 723 | "location": { 724 | "start_line": 11, 725 | "start_column": 18, 726 | "last_line": 11, 727 | "last_column": 26, 728 | "length": 9, 729 | "line": 11, 730 | "column": 18 731 | } 732 | }, 733 | { 734 | "severity": "convention", 735 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 736 | "cop_name": "Style/StringLiterals", 737 | "corrected": false, 738 | "location": { 739 | "start_line": 27, 740 | "start_column": 14, 741 | "last_line": 27, 742 | "last_column": 20, 743 | "length": 7, 744 | "line": 27, 745 | "column": 14 746 | } 747 | }, 748 | { 749 | "severity": "convention", 750 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 751 | "cop_name": "Style/StringLiterals", 752 | "corrected": false, 753 | "location": { 754 | "start_line": 28, 755 | "start_column": 14, 756 | "last_line": 28, 757 | "last_column": 23, 758 | "length": 10, 759 | "line": 28, 760 | "column": 14 761 | } 762 | }, 763 | { 764 | "severity": "convention", 765 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 766 | "cop_name": "Style/StringLiterals", 767 | "corrected": false, 768 | "location": { 769 | "start_line": 32, 770 | "start_column": 30, 771 | "last_line": 32, 772 | "last_column": 39, 773 | "length": 10, 774 | "line": 32, 775 | "column": 30 776 | } 777 | }, 778 | { 779 | "severity": "convention", 780 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 781 | "cop_name": "Style/StringLiterals", 782 | "corrected": false, 783 | "location": { 784 | "start_line": 33, 785 | "start_column": 32, 786 | "last_line": 33, 787 | "last_column": 43, 788 | "length": 12, 789 | "line": 33, 790 | "column": 32 791 | } 792 | }, 793 | { 794 | "severity": "convention", 795 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 796 | "cop_name": "Style/StringLiterals", 797 | "corrected": false, 798 | "location": { 799 | "start_line": 33, 800 | "start_column": 58, 801 | "last_line": 33, 802 | "last_column": 68, 803 | "length": 11, 804 | "line": 33, 805 | "column": 58 806 | } 807 | }, 808 | { 809 | "severity": "convention", 810 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 811 | "cop_name": "Style/StringLiterals", 812 | "corrected": false, 813 | "location": { 814 | "start_line": 36, 815 | "start_column": 28, 816 | "last_line": 36, 817 | "last_column": 33, 818 | "length": 6, 819 | "line": 36, 820 | "column": 28 821 | } 822 | }, 823 | { 824 | "severity": "convention", 825 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 826 | "cop_name": "Style/StringLiterals", 827 | "corrected": false, 828 | "location": { 829 | "start_line": 37, 830 | "start_column": 38, 831 | "last_line": 37, 832 | "last_column": 49, 833 | "length": 12, 834 | "line": 37, 835 | "column": 38 836 | } 837 | }, 838 | { 839 | "severity": "convention", 840 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 841 | "cop_name": "Style/StringLiterals", 842 | "corrected": false, 843 | "location": { 844 | "start_line": 38, 845 | "start_column": 36, 846 | "last_line": 38, 847 | "last_column": 46, 848 | "length": 11, 849 | "line": 38, 850 | "column": 36 851 | } 852 | }, 853 | { 854 | "severity": "convention", 855 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 856 | "cop_name": "Style/StringLiterals", 857 | "corrected": false, 858 | "location": { 859 | "start_line": 39, 860 | "start_column": 41, 861 | "last_line": 39, 862 | "last_column": 54, 863 | "length": 14, 864 | "line": 39, 865 | "column": 41 866 | } 867 | }, 868 | { 869 | "severity": "convention", 870 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 871 | "cop_name": "Style/StringLiterals", 872 | "corrected": false, 873 | "location": { 874 | "start_line": 40, 875 | "start_column": 39, 876 | "last_line": 40, 877 | "last_column": 51, 878 | "length": 13, 879 | "line": 40, 880 | "column": 39 881 | } 882 | }, 883 | { 884 | "severity": "convention", 885 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 886 | "cop_name": "Style/StringLiterals", 887 | "corrected": false, 888 | "location": { 889 | "start_line": 41, 890 | "start_column": 60, 891 | "last_line": 41, 892 | "last_column": 69, 893 | "length": 10, 894 | "line": 41, 895 | "column": 60 896 | } 897 | }, 898 | { 899 | "severity": "convention", 900 | "message": "Put a comma after the last item of a multiline hash.", 901 | "cop_name": "Style/TrailingCommaInHashLiteral", 902 | "corrected": false, 903 | "location": { 904 | "start_line": 42, 905 | "start_column": 15, 906 | "last_line": 42, 907 | "last_column": 43, 908 | "length": 29, 909 | "line": 42, 910 | "column": 15 911 | } 912 | }, 913 | { 914 | "severity": "convention", 915 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 916 | "cop_name": "Style/StringLiterals", 917 | "corrected": false, 918 | "location": { 919 | "start_line": 42, 920 | "start_column": 34, 921 | "last_line": 42, 922 | "last_column": 42, 923 | "length": 9, 924 | "line": 42, 925 | "column": 34 926 | } 927 | }, 928 | { 929 | "severity": "convention", 930 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 931 | "cop_name": "Style/StringLiterals", 932 | "corrected": false, 933 | "location": { 934 | "start_line": 56, 935 | "start_column": 18, 936 | "last_line": 56, 937 | "last_column": 26, 938 | "length": 9, 939 | "line": 56, 940 | "column": 18 941 | } 942 | }, 943 | { 944 | "severity": "convention", 945 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 946 | "cop_name": "Style/StringLiterals", 947 | "corrected": false, 948 | "location": { 949 | "start_line": 56, 950 | "start_column": 29, 951 | "last_line": 56, 952 | "last_column": 43, 953 | "length": 15, 954 | "line": 56, 955 | "column": 29 956 | } 957 | } 958 | ] 959 | }, 960 | { 961 | "path": "spec/github_check_run_service_spec.rb", 962 | "offenses": [ 963 | { 964 | "severity": "convention", 965 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 966 | "cop_name": "Style/StringLiterals", 967 | "corrected": false, 968 | "location": { 969 | "start_line": 3, 970 | "start_column": 9, 971 | "last_line": 3, 972 | "last_column": 28, 973 | "length": 20, 974 | "line": 3, 975 | "column": 9 976 | } 977 | }, 978 | { 979 | "severity": "convention", 980 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 981 | "cop_name": "Style/StringLiterals", 982 | "corrected": false, 983 | "location": { 984 | "start_line": 6, 985 | "start_column": 41, 986 | "last_line": 6, 987 | "last_column": 69, 988 | "length": 29, 989 | "line": 6, 990 | "column": 41 991 | } 992 | }, 993 | { 994 | "severity": "convention", 995 | "message": "Space inside { detected.", 996 | "cop_name": "Layout/SpaceInsideHashLiteralBraces", 997 | "corrected": false, 998 | "location": { 999 | "start_line": 7, 1000 | "start_column": 24, 1001 | "last_line": 7, 1002 | "last_column": 24, 1003 | "length": 1, 1004 | "line": 7, 1005 | "column": 24 1006 | } 1007 | }, 1008 | { 1009 | "severity": "convention", 1010 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1011 | "cop_name": "Style/StringLiterals", 1012 | "corrected": false, 1013 | "location": { 1014 | "start_line": 7, 1015 | "start_column": 30, 1016 | "last_line": 7, 1017 | "last_column": 34, 1018 | "length": 5, 1019 | "line": 7, 1020 | "column": 30 1021 | } 1022 | }, 1023 | { 1024 | "severity": "convention", 1025 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1026 | "cop_name": "Style/StringLiterals", 1027 | "corrected": false, 1028 | "location": { 1029 | "start_line": 7, 1030 | "start_column": 44, 1031 | "last_line": 7, 1032 | "last_column": 50, 1033 | "length": 7, 1034 | "line": 7, 1035 | "column": 44 1036 | } 1037 | }, 1038 | { 1039 | "severity": "convention", 1040 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1041 | "cop_name": "Style/StringLiterals", 1042 | "corrected": false, 1043 | "location": { 1044 | "start_line": 7, 1045 | "start_column": 60, 1046 | "last_line": 7, 1047 | "last_column": 66, 1048 | "length": 7, 1049 | "line": 7, 1050 | "column": 60 1051 | } 1052 | }, 1053 | { 1054 | "severity": "convention", 1055 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1056 | "cop_name": "Style/StringLiterals", 1057 | "corrected": false, 1058 | "location": { 1059 | "start_line": 7, 1060 | "start_column": 75, 1061 | "last_line": 7, 1062 | "last_column": 91, 1063 | "length": 17, 1064 | "line": 7, 1065 | "column": 75 1066 | } 1067 | }, 1068 | { 1069 | "severity": "convention", 1070 | "message": "Space inside } detected.", 1071 | "cop_name": "Layout/SpaceInsideHashLiteralBraces", 1072 | "corrected": false, 1073 | "location": { 1074 | "start_line": 7, 1075 | "start_column": 92, 1076 | "last_line": 7, 1077 | "last_column": 92, 1078 | "length": 1, 1079 | "line": 7, 1080 | "column": 92 1081 | } 1082 | }, 1083 | { 1084 | "severity": "convention", 1085 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1086 | "cop_name": "Style/StringLiterals", 1087 | "corrected": false, 1088 | "location": { 1089 | "start_line": 10, 1090 | "start_column": 6, 1091 | "last_line": 10, 1092 | "last_column": 11, 1093 | "length": 6, 1094 | "line": 10, 1095 | "column": 6 1096 | } 1097 | }, 1098 | { 1099 | "severity": "convention", 1100 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1101 | "cop_name": "Style/StringLiterals", 1102 | "corrected": false, 1103 | "location": { 1104 | "start_line": 11, 1105 | "start_column": 24, 1106 | "last_line": 11, 1107 | "last_column": 89, 1108 | "length": 66, 1109 | "line": 11, 1110 | "column": 24 1111 | } 1112 | }, 1113 | { 1114 | "severity": "convention", 1115 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1116 | "cop_name": "Style/StringLiterals", 1117 | "corrected": false, 1118 | "location": { 1119 | "start_line": 12, 1120 | "start_column": 37, 1121 | "last_line": 12, 1122 | "last_column": 40, 1123 | "length": 4, 1124 | "line": 12, 1125 | "column": 37 1126 | } 1127 | }, 1128 | { 1129 | "severity": "convention", 1130 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1131 | "cop_name": "Style/StringLiterals", 1132 | "corrected": false, 1133 | "location": { 1134 | "start_line": 14, 1135 | "start_column": 24, 1136 | "last_line": 14, 1137 | "last_column": 86, 1138 | "length": 63, 1139 | "line": 14, 1140 | "column": 24 1141 | } 1142 | } 1143 | ] 1144 | }, 1145 | { 1146 | "path": "spec/report_adapter_spec.rb", 1147 | "offenses": [ 1148 | { 1149 | "severity": "convention", 1150 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1151 | "cop_name": "Style/StringLiterals", 1152 | "corrected": false, 1153 | "location": { 1154 | "start_line": 3, 1155 | "start_column": 9, 1156 | "last_line": 3, 1157 | "last_column": 28, 1158 | "length": 20, 1159 | "line": 3, 1160 | "column": 9 1161 | } 1162 | }, 1163 | { 1164 | "severity": "convention", 1165 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1166 | "cop_name": "Style/StringLiterals", 1167 | "corrected": false, 1168 | "location": { 1169 | "start_line": 7, 1170 | "start_column": 20, 1171 | "last_line": 7, 1172 | "last_column": 48, 1173 | "length": 29, 1174 | "line": 7, 1175 | "column": 20 1176 | } 1177 | }, 1178 | { 1179 | "severity": "convention", 1180 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1181 | "cop_name": "Style/StringLiterals", 1182 | "corrected": false, 1183 | "location": { 1184 | "start_line": 12, 1185 | "start_column": 6, 1186 | "last_line": 12, 1187 | "last_column": 18, 1188 | "length": 13, 1189 | "line": 12, 1190 | "column": 6 1191 | } 1192 | }, 1193 | { 1194 | "severity": "convention", 1195 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1196 | "cop_name": "Style/StringLiterals", 1197 | "corrected": false, 1198 | "location": { 1199 | "start_line": 14, 1200 | "start_column": 26, 1201 | "last_line": 14, 1202 | "last_column": 34, 1203 | "length": 9, 1204 | "line": 14, 1205 | "column": 26 1206 | } 1207 | }, 1208 | { 1209 | "severity": "convention", 1210 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1211 | "cop_name": "Style/StringLiterals", 1212 | "corrected": false, 1213 | "location": { 1214 | "start_line": 17, 1215 | "start_column": 6, 1216 | "last_line": 17, 1217 | "last_column": 15, 1218 | "length": 10, 1219 | "line": 17, 1220 | "column": 6 1221 | } 1222 | }, 1223 | { 1224 | "severity": "convention", 1225 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1226 | "cop_name": "Style/StringLiterals", 1227 | "corrected": false, 1228 | "location": { 1229 | "start_line": 19, 1230 | "start_column": 26, 1231 | "last_line": 19, 1232 | "last_column": 47, 1233 | "length": 22, 1234 | "line": 19, 1235 | "column": 26 1236 | } 1237 | }, 1238 | { 1239 | "severity": "convention", 1240 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1241 | "cop_name": "Style/StringLiterals", 1242 | "corrected": false, 1243 | "location": { 1244 | "start_line": 22, 1245 | "start_column": 11, 1246 | "last_line": 22, 1247 | "last_column": 42, 1248 | "length": 32, 1249 | "line": 22, 1250 | "column": 11 1251 | } 1252 | }, 1253 | { 1254 | "severity": "convention", 1255 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1256 | "cop_name": "Style/StringLiterals", 1257 | "corrected": false, 1258 | "location": { 1259 | "start_line": 23, 1260 | "start_column": 8, 1261 | "last_line": 23, 1262 | "last_column": 21, 1263 | "length": 14, 1264 | "line": 23, 1265 | "column": 8 1266 | } 1267 | }, 1268 | { 1269 | "severity": "convention", 1270 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1271 | "cop_name": "Style/StringLiterals", 1272 | "corrected": false, 1273 | "location": { 1274 | "start_line": 26, 1275 | "start_column": 9, 1276 | "last_line": 26, 1277 | "last_column": 14, 1278 | "length": 6, 1279 | "line": 26, 1280 | "column": 9 1281 | } 1282 | }, 1283 | { 1284 | "severity": "convention", 1285 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1286 | "cop_name": "Style/StringLiterals", 1287 | "corrected": false, 1288 | "location": { 1289 | "start_line": 26, 1290 | "start_column": 19, 1291 | "last_line": 26, 1292 | "last_column": 27, 1293 | "length": 9, 1294 | "line": 26, 1295 | "column": 19 1296 | } 1297 | }, 1298 | { 1299 | "severity": "convention", 1300 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1301 | "cop_name": "Style/StringLiterals", 1302 | "corrected": false, 1303 | "location": { 1304 | "start_line": 27, 1305 | "start_column": 9, 1306 | "last_line": 27, 1307 | "last_column": 20, 1308 | "length": 12, 1309 | "line": 27, 1310 | "column": 9 1311 | } 1312 | }, 1313 | { 1314 | "severity": "convention", 1315 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1316 | "cop_name": "Style/StringLiterals", 1317 | "corrected": false, 1318 | "location": { 1319 | "start_line": 28, 1320 | "start_column": 9, 1321 | "last_line": 28, 1322 | "last_column": 18, 1323 | "length": 10, 1324 | "line": 28, 1325 | "column": 9 1326 | } 1327 | }, 1328 | { 1329 | "severity": "convention", 1330 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1331 | "cop_name": "Style/StringLiterals", 1332 | "corrected": false, 1333 | "location": { 1334 | "start_line": 29, 1335 | "start_column": 9, 1336 | "last_line": 29, 1337 | "last_column": 22, 1338 | "length": 14, 1339 | "line": 29, 1340 | "column": 9 1341 | } 1342 | }, 1343 | { 1344 | "severity": "convention", 1345 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1346 | "cop_name": "Style/StringLiterals", 1347 | "corrected": false, 1348 | "location": { 1349 | "start_line": 30, 1350 | "start_column": 9, 1351 | "last_line": 30, 1352 | "last_column": 20, 1353 | "length": 12, 1354 | "line": 30, 1355 | "column": 9 1356 | } 1357 | }, 1358 | { 1359 | "severity": "convention", 1360 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1361 | "cop_name": "Style/StringLiterals", 1362 | "corrected": false, 1363 | "location": { 1364 | "start_line": 31, 1365 | "start_column": 9, 1366 | "last_line": 31, 1367 | "last_column": 26, 1368 | "length": 18, 1369 | "line": 31, 1370 | "column": 9 1371 | } 1372 | }, 1373 | { 1374 | "severity": "convention", 1375 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1376 | "cop_name": "Style/StringLiterals", 1377 | "corrected": false, 1378 | "location": { 1379 | "start_line": 31, 1380 | "start_column": 31, 1381 | "last_line": 31, 1382 | "last_column": 39, 1383 | "length": 9, 1384 | "line": 31, 1385 | "column": 31 1386 | } 1387 | }, 1388 | { 1389 | "severity": "convention", 1390 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1391 | "cop_name": "Style/StringLiterals", 1392 | "corrected": false, 1393 | "location": { 1394 | "start_line": 32, 1395 | "start_column": 9, 1396 | "last_line": 32, 1397 | "last_column": 17, 1398 | "length": 9, 1399 | "line": 32, 1400 | "column": 9 1401 | } 1402 | }, 1403 | { 1404 | "severity": "convention", 1405 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1406 | "cop_name": "Style/StringLiterals", 1407 | "corrected": false, 1408 | "location": { 1409 | "start_line": 32, 1410 | "start_column": 22, 1411 | "last_line": 32, 1412 | "last_column": 77, 1413 | "length": 56, 1414 | "line": 32, 1415 | "column": 22 1416 | } 1417 | }, 1418 | { 1419 | "severity": "convention", 1420 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1421 | "cop_name": "Style/StringLiterals", 1422 | "corrected": false, 1423 | "location": { 1424 | "start_line": 37, 1425 | "start_column": 11, 1426 | "last_line": 37, 1427 | "last_column": 46, 1428 | "length": 36, 1429 | "line": 37, 1430 | "column": 11 1431 | } 1432 | }, 1433 | { 1434 | "severity": "convention", 1435 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1436 | "cop_name": "Style/StringLiterals", 1437 | "corrected": false, 1438 | "location": { 1439 | "start_line": 38, 1440 | "start_column": 8, 1441 | "last_line": 38, 1442 | "last_column": 21, 1443 | "length": 14, 1444 | "line": 38, 1445 | "column": 8 1446 | } 1447 | }, 1448 | { 1449 | "severity": "convention", 1450 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1451 | "cop_name": "Style/StringLiterals", 1452 | "corrected": false, 1453 | "location": { 1454 | "start_line": 41, 1455 | "start_column": 9, 1456 | "last_line": 41, 1457 | "last_column": 14, 1458 | "length": 6, 1459 | "line": 41, 1460 | "column": 9 1461 | } 1462 | }, 1463 | { 1464 | "severity": "convention", 1465 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1466 | "cop_name": "Style/StringLiterals", 1467 | "corrected": false, 1468 | "location": { 1469 | "start_line": 41, 1470 | "start_column": 19, 1471 | "last_line": 41, 1472 | "last_column": 27, 1473 | "length": 9, 1474 | "line": 41, 1475 | "column": 19 1476 | } 1477 | }, 1478 | { 1479 | "severity": "convention", 1480 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1481 | "cop_name": "Style/StringLiterals", 1482 | "corrected": false, 1483 | "location": { 1484 | "start_line": 42, 1485 | "start_column": 9, 1486 | "last_line": 42, 1487 | "last_column": 20, 1488 | "length": 12, 1489 | "line": 42, 1490 | "column": 9 1491 | } 1492 | }, 1493 | { 1494 | "severity": "convention", 1495 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1496 | "cop_name": "Style/StringLiterals", 1497 | "corrected": false, 1498 | "location": { 1499 | "start_line": 43, 1500 | "start_column": 9, 1501 | "last_line": 43, 1502 | "last_column": 18, 1503 | "length": 10, 1504 | "line": 43, 1505 | "column": 9 1506 | } 1507 | }, 1508 | { 1509 | "severity": "convention", 1510 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1511 | "cop_name": "Style/StringLiterals", 1512 | "corrected": false, 1513 | "location": { 1514 | "start_line": 44, 1515 | "start_column": 9, 1516 | "last_line": 44, 1517 | "last_column": 26, 1518 | "length": 18, 1519 | "line": 44, 1520 | "column": 9 1521 | } 1522 | }, 1523 | { 1524 | "severity": "convention", 1525 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1526 | "cop_name": "Style/StringLiterals", 1527 | "corrected": false, 1528 | "location": { 1529 | "start_line": 44, 1530 | "start_column": 31, 1531 | "last_line": 44, 1532 | "last_column": 39, 1533 | "length": 9, 1534 | "line": 44, 1535 | "column": 31 1536 | } 1537 | }, 1538 | { 1539 | "severity": "convention", 1540 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1541 | "cop_name": "Style/StringLiterals", 1542 | "corrected": false, 1543 | "location": { 1544 | "start_line": 45, 1545 | "start_column": 9, 1546 | "last_line": 45, 1547 | "last_column": 17, 1548 | "length": 9, 1549 | "line": 45, 1550 | "column": 9 1551 | } 1552 | }, 1553 | { 1554 | "severity": "convention", 1555 | "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.", 1556 | "cop_name": "Style/StringLiterals", 1557 | "corrected": false, 1558 | "location": { 1559 | "start_line": 45, 1560 | "start_column": 22, 1561 | "last_line": 45, 1562 | "last_column": 57, 1563 | "length": 36, 1564 | "line": 45, 1565 | "column": 22 1566 | } 1567 | } 1568 | ] 1569 | } 1570 | ], 1571 | "summary": { 1572 | "offense_count": 122, 1573 | "target_file_count": 8, 1574 | "inspected_file_count": 8 1575 | } 1576 | } 1577 | -------------------------------------------------------------------------------- /spec/github_check_run_service_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "./spec/spec_helper" 4 | 5 | describe GithubCheckRunService do 6 | let(:standardrb_report) { JSON(File.read("./spec/fixtures/report.json")) } 7 | let(:github_data) { {sha: "sha", token: "token", owner: "owner", repo: "repository_name"} } 8 | let(:service) { GithubCheckRunService.new(standardrb_report, github_data, ReportAdapter) } 9 | 10 | it "#run" do 11 | stub_request(:any, "https://api.github.com/repos/owner/repository_name/check-runs/id") 12 | .to_return(status: 200, body: "{}") 13 | 14 | stub_request(:any, "https://api.github.com/repos/owner/repository_name/check-runs") 15 | .to_return(status: 200, body: '{"id": "id"}') 16 | 17 | output = service.run 18 | expect(output).to be_a(Hash) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/report_adapter_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "./spec/spec_helper" 4 | 5 | describe ReportAdapter do 6 | let(:standardrb_report) do 7 | JSON(File.read("./spec/fixtures/report.json")) 8 | end 9 | 10 | let(:adapter) { ReportAdapter } 11 | 12 | it ".conclusion" do 13 | result = adapter.conclusion(standardrb_report) 14 | expect(result).to eq("failure") 15 | end 16 | 17 | it ".summary" do 18 | result = adapter.summary(standardrb_report) 19 | expect(result).to eq("122 offense(s) found") 20 | end 21 | 22 | context "when error is on the same line" do 23 | it ".annotations" do 24 | result = adapter.annotations(standardrb_report) 25 | expect(result.first).to eq( 26 | "path" => "Gemfile", 27 | "start_line" => 3, 28 | "end_line" => 3, 29 | "start_column" => 8, 30 | "end_column" => 29, 31 | "annotation_level" => "failure", 32 | "message" => "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping." 33 | ) 34 | end 35 | end 36 | 37 | context "when error is not on the same line" do 38 | it ".annotations" do 39 | result = adapter.annotations(standardrb_report) 40 | expect(result[1]).to eq( 41 | "path" => "Gemfile", 42 | "start_line" => 39, 43 | "end_line" => 40, 44 | "annotation_level" => "failure", 45 | "message" => "Put a comma after the last item of a multiline hash." 46 | ) 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "webmock/rspec" 4 | require "json" 5 | require "./lib/report_adapter" 6 | require "./lib/github_check_run_service" 7 | require "./lib/github_client" 8 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 2.0.0 2 | --------------------------------------------------------------------------------