Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
m4i committed Jun 21, 2014
1 parent 14c4cb0 commit 4bd4da7
Show file tree
Hide file tree
Showing 15 changed files with 627 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bin/rubocop-git
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env ruby

require 'rubocop/git'
require 'rubocop/git/cli'

RuboCop::Git::CLI.new.run
235 changes: 235 additions & 0 deletions hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
AccessorMethodName:
Enabled: false

Alias:
Enabled: false

ArrayJoin:
Enabled: false

AsciiComments:
Enabled: false

AsciiIdentifiers:
Enabled: false

Attr:
Enabled: false

BlockNesting:
Enabled: false

CaseEquality:
Enabled: false

CharacterLiteral:
Enabled: false

ClassLength:
Enabled: false

ClassVars:
Enabled: false

CollectionMethods:
PreferredMethods:
find: detect
reduce: inject
collect: map
find_all: select

ColonMethodCall:
Enabled: false

CommentAnnotation:
Enabled: false

CyclomaticComplexity:
Enabled: false

Delegate:
Enabled: false

DeprecatedHashMethods:
Enabled: false

Documentation:
Enabled: false

DotPosition:
EnforcedStyle: trailing

DoubleNegation:
Enabled: false

EmptyLiteral:
Enabled: false

Encoding:
Enabled: false

EvenOdd:
Enabled: false

FileName:
Enabled: false

FlipFlop:
Enabled: false

FormatString:
Enabled: false

GlobalVars:
Enabled: false

IfUnlessModifier:
Enabled: false

IfWithSemicolon:
Enabled: false

Lambda:
Enabled: false

LambdaCall:
Enabled: false

LineEndConcatenation:
Enabled: false

LineLength:
Max: 80

MethodLength:
Enabled: false

ModuleFunction:
Enabled: false

NegatedIf:
Enabled: false

NegatedWhile:
Enabled: false

NilComparison:
Enabled: false

Not:
Enabled: false

NumericLiterals:
Enabled: false

OneLineConditional:
Enabled: false

OpMethod:
Enabled: false

ParameterLists:
Enabled: false

PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'

PerlBackrefs:
Enabled: false

PredicateName:
NamePrefixBlacklist:
- is_

Proc:
Enabled: false

RaiseArgs:
Enabled: false

RegexpLiteral:
Enabled: false

SelfAssignment:
Enabled: false

SingleLineBlockParams:
Enabled: false

SingleLineMethods:
Enabled: false

SignalException:
Enabled: false

SpecialGlobalVars:
Enabled: false

VariableInterpolation:
Enabled: false

TrailingComma:
Enabled: false

TrivialAccessors:
Enabled: false

VariableInterpolation:
Enabled: false

WhenThen:
Enabled: false

WhileUntilModifier:
Enabled: false

WordArray:
Enabled: false

# Lint

AmbiguousOperator:
Enabled: false

AmbiguousRegexpLiteral:
Enabled: false

AssignmentInCondition:
Enabled: false

ConditionPosition:
Enabled: false

DeprecatedClassMethods:
Enabled: false

ElseLayout:
Enabled: false

HandleExceptions:
Enabled: false

InvalidCharacterLiteral:
Enabled: false

LiteralInCondition:
Enabled: false

LiteralInInterpolation:
Enabled: false

Loop:
Enabled: false

ParenthesesAsGroupedExpression:
Enabled: false

RequireParentheses:
Enabled: false

UnderscorePrefixedVariableName:
Enabled: false

Void:
Enabled: false
15 changes: 14 additions & 1 deletion lib/rubocop/git.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
require 'rubocop/git/version'
require 'rubocop'
require 'active_support/core_ext/module/attribute_accessors'

module RuboCop
module Git
# Your code goes here...
autoload :FileCollection, 'rubocop/git/file_collection'
autoload :FileViolation, 'rubocop/git/file_violation'
autoload :Line, 'rubocop/git/line'
autoload :ModifiedFile, 'rubocop/git/modified_file'
autoload :Patch, 'rubocop/git/patch'
autoload :PseudoPullRequest, 'rubocop/git/pseudo_pull_request'
autoload :PseudoResource, 'rubocop/git/pseudo_resource'
autoload :Runner, 'rubocop/git/runner'
autoload :StyleChecker, 'rubocop/git/style_checker'
autoload :StyleGuide, 'rubocop/git/style_guide'

mattr_accessor :config_path
end
end
42 changes: 42 additions & 0 deletions lib/rubocop/git/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'rubocop/git'
require 'optparse'

module RuboCop
module Git
class CLI
def run(args = ARGV)
options = parse_arguments(args)
Runner.new.run(options)
end

private

def parse_arguments(args)
options = {}

OptionParser.new do |opt|
opt.on('-c', '--config FILE',
'Specify configuration file') do |config|
options[:config] = config
end

opt.on('--cached', 'git diff --cached') do
options[:cached] = true
end

opt.on('--staged', 'synonym of --cached') do
options[:cached] = true
end

opt.on('--hound', 'Hound compatibility mode') do
options[:hound] = true
end

opt.parse(args)
end

options
end
end
end
end
18 changes: 18 additions & 0 deletions lib/rubocop/git/file_collection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module RuboCop::Git
# copy from https://github.com/thoughtbot/hound/blob/a6a8d3f/app/models/file_collection.rb
class FileCollection
IGNORED_FILES = ['db/schema.rb']

attr_reader :files

def initialize(files)
@files = files
end

def relevant_files
files.reject do |file|
file.removed? || !file.ruby? || IGNORED_FILES.include?(file.filename)
end
end
end
end
5 changes: 5 additions & 0 deletions lib/rubocop/git/file_violation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module RuboCop::Git
# copy from https://github.com/thoughtbot/hound/blob/a6a8d3f/app/models/file_violation.rb
class FileViolation < Struct.new(:filename, :offenses)
end
end
8 changes: 8 additions & 0 deletions lib/rubocop/git/line.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module RuboCop::Git
# copy from https://github.com/thoughtbot/hound/blob/a6a8d3f/app/models/line.rb
class Line < Struct.new(:content, :line_number, :patch_position)
def ==(other_line)
content == other_line.content
end
end
end
Loading

0 comments on commit 4bd4da7

Please sign in to comment.