diff --git a/Rakefile b/Rakefile index 7613feaf5d..4b5648a2e6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,27 @@ require 'yaml' -namespace :lint do - begin - require 'rspec/core/rake_task' +begin + require 'rspec/core/rake_task' +rescue LoadError + warn "Warning: RSpec is not installed. Please run `gem install rspec` to install RSpec." +end + +if defined?(RSpec::Core::RakeTask) + namespace :lint do + desc "Lint reports (excluding schema validation)" + RSpec::Core::RakeTask.new(:yaml) do |t| + t.exclude_pattern = 'spec/schema_validation_spec.rb' + end - RSpec::Core::RakeTask.new(:yaml) - rescue LoadError => e - task :spec do - abort "Please run `gem install rspec` to install RSpec." + desc "Validate report schema" + RSpec::Core::RakeTask.new(:schema) do |t| + t.pattern = 'spec/schema_validation_spec.rb' end end + + desc "Run all linting tasks" + task :lint => [ 'lint:schema', 'lint:yaml' ] + task :default => [ :lint ] end desc "Sync GitHub RubyGem Advisories into this project" @@ -17,6 +29,3 @@ task :sync_github_advisories, [:gem_name] do |_, args| require_relative "lib/github_advisory_sync" GitHub::GitHubAdvisorySync.sync(gem_name: args[:gem_name]) end - -task :lint => ['lint:yaml'] -task :default => :lint