Skip to content

Instantly share code, notes, and snippets.

@ainame
Last active April 22, 2021 09:26

Revisions

  1. ainame revised this gist Apr 22, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions rubocop_todo_yml_parser.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    require 'yaml'
    cops = File.read('.rubocop_todo.yml')
    .split("\n\n")
    .drop(1)
  2. ainame created this gist Apr 22, 2021.
    12 changes: 12 additions & 0 deletions rubocop_todo_yml_parser.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    cops = File.read('.rubocop_todo.yml')
    .split("\n\n")
    .drop(1)
    .map {
    {
    count: _1.match(/Offense count: (\d+)/).captures[0].to_i,
    yaml: YAML.load(_1),
    auto_correct: _1.match(/Cop supports --auto-correct/) != nil
    }
    }
    # => {:count=>1, :yaml=>{"Style/TrailingCommaInHashLiteral"=>{"Enabled"=>false}}, :auto_correct=>true}
    # ...