Skip to content

Commit

Permalink
[POC][WIP] Add linter to CLI
Browse files Browse the repository at this point in the history
Allows linting of single branch, or targeted file from that branch.

Currently only running `Rubocop` (since that is all I had available to
test against), but the concept should work for the other linters as
well.
  • Loading branch information
NickLaMuro committed Feb 2, 2021
1 parent d63a132 commit 400e645
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/manageiq/style/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ def parse_cli_options
synopsis "\nThe ManageIQ community's style configuration utility."
version "v#{ManageIQ::Style::VERSION}\n"

opt :install, "Install or update the style configurations", :default => false, :required => true
opt :format, "TODO: How to format the linter output", :default => "emacs"
opt :install, "Install or update the style configurations", :default => false
opt :lint, "Run linters for current changes", :default => false
opt :linters, "Linters to run for current changes", :default => ["rubocop"]
end
end

def run
install if @opts[:install]
lint if @opts[:lint]
end

def install
Expand All @@ -38,6 +42,20 @@ def install
update_gem_source
end

def lint
require 'more_core_extensions/all'

require 'manageiq/style/git_service/branch'
require 'manageiq/style/git_service/diff'

require 'manageiq/style/linter/base'
require 'manageiq/style/linter/haml'
require 'manageiq/style/linter/rubocop'
require 'manageiq/style/linter/yaml'

Linter::Rubocop.new(ARGV).run
end

private

def check_for_codeclimate_channel
Expand Down

0 comments on commit 400e645

Please sign in to comment.