<commit_before>module RubyLint
  module Analysis
    ##
    # The {RubyLint::Analysis::UselessRuby} class checks for various useless
    # Ruby features, the use of redundant tokens such as `then` for `if`
    # statements and various other pedantics.
    #
    class Pedantics < Base
      register 'pedantics'

      [:if, :unless, :until, :while].each do |type|
        define_method("on_#{type}") do |node|
          if node.location.respond_to?(:begin) and node.location.begin
            check_begin_token(node)
          end
        end
      end

      [:on_preexe, :on_postexe].each do |method|
        define_method(method) do |node|
          warning('BEGIN/END is useless', node)<commit_msg>Correct docs of the Pedantics analysis class.<commit_after>module RubyLint
  module Analysis
    ##
    # This class adds (pedantic) warnings for various features that aren't
    # really that useful or needed. This serves mostly as a simple example on
    # how to write an analysis class.
    #
    # Currently warnings are added for the following:
    #
    # * BEGIN/END blocks
    # * Statements that use `then` or `do` when it's not needed
    #
    # For example:
    #
    #     BEGIN { puts 'foo' }
    #
    # This would result in the warning "BEGIN/END is useless" being added.
    #
    class Pedantics < Base
      register 'pedantics'

      [:if, :unless, :until, :while].each do |type|
        define_method("on_#{type}") do |node|
          if node.location.respond_to?(:begin) and node.location.begin
            check_begin_token(node)
          end
        end
      end

      [:on_preexe, :on_postexe].each do |method|
        define_method(method) do |node|
          warning('BEGIN/END is useless', node)
{'fraction_non_alphanumeric': 0.097631426920855, 'fraction_numerical': 0.0, 'mean_word_length': 2.470941883767535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5918801', 'n_tokens_mistral': 532, 'n_tokens_neox': 502, 'n_words': 167}