Skip to content

Commit

Permalink
Merge pull request #8 from shopsmart/enforce_linter
Browse files Browse the repository at this point in the history
Enforce Linter
  • Loading branch information
wenga86 authored Mar 7, 2018
2 parents 4737485 + 7ae9df7 commit f7feca1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bd_lint (0.2.1.4)
bd_lint (0.2.2)
brakeman
bundler-audit
execjs
Expand Down Expand Up @@ -206,4 +206,4 @@ DEPENDENCIES
thor

BUNDLED WITH
1.16.0
1.16.1
6 changes: 5 additions & 1 deletion lib/bd_lint.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
require "bd_lint/rvm_version"
require "bd_lint/validator"
require "pre-commit"
require "plugins/pre_commit/checks/jscs"

# Run this on application initialization
BdLint::Validator.check
BdLint::RvmVersion.check

module BdLint
def self.run
RvmVersion.check
PreCommit.run
end
end
4 changes: 2 additions & 2 deletions lib/bd_lint/rvm_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "mkmf"

module BdLint
class RvmVersion
require "mkmf"

def self.check
if MakeMakefile.find_executable("rvm")
rvm_current = %x(rvm current).chomp
Expand Down
19 changes: 19 additions & 0 deletions lib/bd_lint/validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module BdLint
class Validator
GIT_HOOK_PATH = ".git/hooks/pre-commit".freeze

class GitHookError < StandardError; end

def self.check
raise GitHookError, "Please run `bundle exec #{message}`" if invalid?
end

def self.invalid?
!defined?(Rake) && !File.exist?(GIT_HOOK_PATH)
end

def self.message
defined?(Rails) ? "rails g pre_commit" : "rake bd_lint:generate:pre_commit"
end
end
end
2 changes: 1 addition & 1 deletion lib/bd_lint/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BdLint
VERSION = "0.2.1.4".freeze
VERSION = "0.2.2".freeze
end
2 changes: 2 additions & 0 deletions test_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# Prevents test from not running
require "rake"
# require "rails/test_unit/railtie"

Bundler.require(*Rails.groups)
Expand Down

0 comments on commit f7feca1

Please sign in to comment.