<commit_before>require 'rake'
require 'rake/tasklib'

module FoodCritic
  module Rake
    class LintTask < ::Rake::TaskLib
      attr_accessor :name, :files
      attr_writer :options

      def initialize(name = :foodcritic)
        @name = name
        @files = [Dir.pwd]
        @options = {}
        yield self if block_given?
        define
      end

      def options
        {:fail_tags => ['correctness'], # differs to default cmd-line behaviour
         :cookbook_paths => @files,
         :exclude_paths => ['test/**/*', 'spec/**/*', 'features/**/*']
        }.merge(@options)
      end

      def define
        desc "Lint Chef cookbooks"
        task(name) do
          result = FoodCritic::Linter.new.check(options)
          if result.warnings.any?
            puts result
          end

          fail result.to_s if result.failed?
        end
      end

    end
  end
end<commit_msg>Allow to override description of Rake task<commit_after>require 'rake'
require 'rake/tasklib'

module FoodCritic
  module Rake
    class LintTask < ::Rake::TaskLib
      attr_accessor :name, :files
      attr_writer :options

      def initialize(name = :foodcritic)
        @name = name
        @files = [Dir.pwd]
        @options = {}
        yield self if block_given?
        define
      end

      def options
        {:fail_tags => ['correctness'], # differs to default cmd-line behaviour
         :cookbook_paths => @files,
         :exclude_paths => ['test/**/*', 'spec/**/*', 'features/**/*']
        }.merge(@options)
      end

      def define
        desc "Lint Chef cookbooks" unless ::Rake.application.last_comment
        task(name) do
          result = FoodCritic::Linter.new.check(options)
          if result.warnings.any?
            puts result
          end

          fail result.to_s if result.failed?
        end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.10813704496788008, 'fraction_numerical': 0.0, 'mean_word_length': 1.934065934065934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7431695', 'n_tokens_mistral': 564, 'n_tokens_neox': 541, 'n_words': 149}