Fix incorrect mutator comments

I used a script which detects duplicate comments:

    require 'parser/current'
    require 'pathname'

    require 'concord'

    class Comment
      include Equalizer.new(:text)

      def initialize(path, comment)
        @path    = path
        @comment = comment
      end

      def text
        comment.text
      end

      def <=>(other)
        text <=> other.text
      end

      attr_reader :path, :comment
    end

    comments =
      Pathname
        .glob('lib/**/*.rb')
        .flat_map do |path|
          Parser::CurrentRuby
            .parse_with_comments(path.read)
            .last
            .map do |comment|
              Comment.new(path, comment)
            end
        end

    @seen = Set.new

    ignores = [
      '#',
      '#   otherwise',
      /\A# [A-Z]\w+\z/,
      /\A# rubocop:disable \w+/,
      /\A# @\w/,
      /\A# @\w/,
      /\A# @\w/,
      /\A# @\w/,
    ]

    duplicates = []

    comments
      .reject do |comment|
        ignores.any? { |ignore| ignore === comment.text }
      end
      .sort
      .group_by { |comment| comment.text }
      .reject { |_, comments| comments.one? }
      .sort_by { |_, comments| comments.size }
      .each do |text, comments|
        next if comments.one?
        warn text

        comments.each do |comment|
          warn "  #{comment.path}:#{comment.comment.loc.line}"
        end
      end
This commit is contained in:
John Backus 2016-06-18 15:28:49 -07:00
parent e104630b90
commit 3a73c1bcbf
No known key found for this signature in database
GPG key ID: 9A91898D0B0B2FBE
3 changed files with 3 additions and 3 deletions

View file

@ -2,7 +2,7 @@ module Mutant
class Mutator
class Node
# OpAsgn mutator
# AndAsgn mutator
class AndAsgn < self
handle(:and_asgn)

View file

@ -1,7 +1,7 @@
module Mutant
class Mutator
class Node
# Namespace for define mutations
# Namespace for `defined?` mutations
class Defined < self
handle(:defined?)

View file

@ -2,7 +2,7 @@ module Mutant
class Mutator
class Node
# OpAsgn mutator
# OrAsgn mutator
class OrAsgn < self
handle(:or_asgn)