-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single rubocop config, also better lint task naming (#1372)
* Single rubocop config, also better lint task naming Fixes #1370 * Setup lint namespace, use rake_helper * Run all lint, still just rubocop but makes future proof
- Loading branch information
Showing
8 changed files
with
94 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,7 @@ tags | |
|
||
# Ignore distribution files | ||
/dist | ||
|
||
# Ignore copies of .rubocop.yml | ||
.rubocop.yml | ||
!/.rubocop.yml |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rubocop/rake_task' | ||
require 'fileutils' | ||
|
||
desc "Lint OnDemand" | ||
task :lint => 'lint:all' | ||
|
||
namespace :lint do | ||
require_relative 'rake_helper' | ||
include RakeHelper | ||
|
||
begin | ||
RuboCop::RakeTask.new(:rubocop, [:path]) do |t, args| | ||
t.options = ["--config=#{PROJ_DIR.join(".rubocop.yml")}"] | ||
default_patterns = [ | ||
"apps/**/*.rb", | ||
"lib/**/*.rb", | ||
"nginx_stage/**/*.rb", | ||
"ood-portal-generator/**/*.rb", | ||
"spec/**/*.rb", | ||
] | ||
t.patterns = args[:path].nil? ? default_patterns : [args[:path]] | ||
end | ||
rescue LoadError | ||
end | ||
|
||
desc "Setup .rubocop.yml files" | ||
task :setup do | ||
source = PROJ_DIR.join('.rubocop.yml') | ||
(ruby_apps + infrastructure).each do |app| | ||
FileUtils.cp(source, app.path.join('.rubocop.yml'), verbose: true) | ||
end | ||
end | ||
|
||
task :all => [:rubocop] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
require "pathname" | ||
|
||
module RakeHelper | ||
def infrastructure | ||
[ | ||
'mod_ood_proxy', | ||
'nginx_stage', | ||
'ood_auth_map', | ||
'ood-portal-generator', | ||
].map { |d| Component.new(d) } | ||
end | ||
|
||
def apps | ||
Dir["#{APPS_DIR}/*"].map { |d| Component.new(d) } | ||
end | ||
|
||
def ruby_apps | ||
apps.select(&:ruby_app?) | ||
end | ||
|
||
def yarn_apps | ||
apps.select(&:package_json?) | ||
end | ||
|
||
class Component | ||
attr_reader :name | ||
attr_reader :path | ||
|
||
def initialize(app) | ||
@name = File.basename(app) | ||
@path = Pathname.new(app) | ||
end | ||
|
||
def ruby_app? | ||
@path.join('config.ru').exist? | ||
end | ||
|
||
def node_app? | ||
@path.join('app.js').exist? | ||
end | ||
|
||
def package_json? | ||
@path.join('package.json').exist? | ||
end | ||
|
||
def gemfile? | ||
@path.join('Gemfile.lock').exist? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters