Class: WayOfWorking::CodeLinting::Hdi::Generators::Exec
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- WayOfWorking::CodeLinting::Hdi::Generators::Exec
- Defined in:
- lib/way_of_working/code_linting/hdi/generators/exec.rb
Overview
This generator runs the linter
Instance Method Summary collapse
-
#prep_and_run_megalinter ⇒ Object
Run MegaLinter.
-
#prep_and_run_rubocop ⇒ Object
Run RuboCop.
- #run_first ⇒ Object
-
#run_last ⇒ Object
We run this last to enable all the linters to run first.
Instance Method Details
#prep_and_run_megalinter ⇒ Object
Run MegaLinter
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/way_of_working/code_linting/hdi/generators/exec.rb', line 30 def prep_and_run_megalinter command = ['npx', 'mega-linter-runner', '--remove-container'] # Configure MegaLinter to only lint a specific file or folder, if defined command.prepend("MEGALINTER_FILES_TO_LINT=\"#{path}\"") if path # We only want reports created in the working directory command.prepend('env', "GITHUB_WORKSPACE=\"#{Dir.pwd}\"") say(Rainbow("\nRunning MegaLinter...").yellow) @megalinter_ok = run_megalinter(command) end |
#prep_and_run_rubocop ⇒ Object
Run RuboCop
23 24 25 26 27 |
# File 'lib/way_of_working/code_linting/hdi/generators/exec.rb', line 23 def prep_and_run_rubocop say(Rainbow('Running RuboCop...').yellow) @rubocop_ok = run_rubocop(ARGV[2..]) end |
#run_first ⇒ Object
16 17 18 19 20 |
# File 'lib/way_of_working/code_linting/hdi/generators/exec.rb', line 16 def run_first @start_time = Time.now say(Rainbow("Limiting linters to #{path}\n").yellow) if path end |
#run_last ⇒ Object
We run this last to enable all the linters to run first
43 44 45 46 47 48 49 50 51 |
# File 'lib/way_of_working/code_linting/hdi/generators/exec.rb', line 43 def run_last say(Rainbow("\nTotal time taken: #{(Time.now - @start_time).to_i} seconds").yellow) if !@rubocop_ok || !@megalinter_ok abort(Rainbow("\nLinter failed!").red) else say(Rainbow("\nLinter Succeeded!").green) end end |