def define_task
      desc 'Run yamllint' unless ::Rake.application.last_description

      task(name) do
        puts 'Running YamlLint...'

        YamlLint.logger.level = Logger::DEBUG if debug

        files_to_check_raw = Rake::FileList.new(paths)
        files_to_exclude = Rake::FileList.new(exclude_paths)
        files_to_check = files_to_check_raw - files_to_exclude

        puts "Checking #{files_to_check.flatten.length} files"
        puts "Excluding #{files_to_exclude.flatten.length} files"

        linter = ::YamlLint::Linter.new(disable_ext_check: disable_ext_check,
                                        extensions: extensions)
        linter.check_all(files_to_check)

        if linter.errors?
          linter.display_errors
          puts "YAML lint found #{linter.errors_count} errors"
          abort('YamlLint failed!') if fail_on_error
        else
          puts 'YamlLint found no errors'
        end
      end
    end
def define_task
      desc 'Run yamllint' unless ::Rake.application.last_description

      task(name) do
        puts 'Running YamlLint...'

        YamlLint.logger.level = Logger::DEBUG if debug

        files_to_check_raw = Rake::FileList.new(paths)
        files_to_exclude = Rake::FileList.new(exclude_paths)
        files_to_check = files_to_check_raw - files_to_exclude

        puts "Checking #{files_to_check.flatten.length} files"
        puts "Excluding #{files_to_exclude.flatten.length} files"

        linter = ::YamlLint::Linter.new(disable_ext_check: disable_ext_check,
                                        extensions: extensions)
        linter.check_all(files_to_check)

        if linter.errors?
          linter.display_errors
          puts "YAML lint found #{linter.errors_count} errors"
          abort('YamlLint failed!') if fail_on_error
        else
          puts 'YamlLint found no errors'
        end
      end
    end
Rake task