Class: PolishGeeks::DevTools::Commands::Rubocop
- Defined in:
- lib/polish_geeks/dev_tools/commands/rubocop.rb
Overview
Command wrapper for Rubocop validation It informs us if code is formatted in a proper way
Constant Summary collapse
- FILES_REGEXP =
Regexp used to get number of inspected files
/(\d+) files inspected/
- OFFENSES_REGEXP =
Regexp used to get number of offenses detected
/(\d+) offense.* detected/
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#execute ⇒ String
Executes this command.
-
#label ⇒ String
Default label for this command.
-
#valid? ⇒ Boolean
True if there were no Rubocop offenses detected.
Methods inherited from Base
#ensure_executable!, #error_message
Instance Method Details
#execute ⇒ String
Executes this command
17 18 19 20 21 22 23 |
# File 'lib/polish_geeks/dev_tools/commands/rubocop.rb', line 17 def execute cmd = ["bundle exec rubocop #{PolishGeeks::DevTools.app_root}"] cmd << "-c #{self.class.config_manager.path}" if self.class.config_manager.present? cmd << '--require rubocop-rspec' if Config.config.rubocop_rspec? cmd << '--display-cop-names' @output = Shell.new.execute(cmd.join(' ')) end |
#label ⇒ String
Returns default label for this command.
31 32 33 34 35 36 37 |
# File 'lib/polish_geeks/dev_tools/commands/rubocop.rb', line 31 def label msg = [] msg << 'Rubocop' msg << 'with RSpec' if Config.config.rubocop_rspec? msg << "(#{files_count} files, #{offenses_count} offenses)" msg.join(' ') end |
#valid? ⇒ Boolean
Returns true if there were no Rubocop offenses detected.
26 27 28 |
# File 'lib/polish_geeks/dev_tools/commands/rubocop.rb', line 26 def valid? offenses_count.zero? end |