Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce Linter #8

Merged
merged 4 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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