diff_cop 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 690340eedf7d92f5e6543c5491489719445bd503
4
+ data.tar.gz: 558ab18936bead3856cb73962771ad99f4502a89
5
+ SHA512:
6
+ metadata.gz: 7a624e30c7060bbd03e51394f2606396d6bfa45a8756570f2be74de346d0cc105955f9ba5e402498371ee8848cbc3863dc6aa30bb2b30fb51a3e7c26e54a1d27
7
+ data.tar.gz: 4d20f50b778f55874fdff32bbb672c3e7a76b491370a66cc7bd21d5af46c25d2ec1d123e9c107ecf3d0164414de339ea228b9787fb16bbca3f745d4cf42fa913
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,243 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "vendor/**/*"
4
+ - "db/schema.rb"
5
+ UseCache: false
6
+ Style/CollectionMethods:
7
+ Description: Preferred collection methods.
8
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
9
+ Enabled: true
10
+ PreferredMethods:
11
+ collect: map
12
+ collect!: map!
13
+ find: detect
14
+ find_all: select
15
+ reduce: inject
16
+ Style/DotPosition:
17
+ Description: Checks the position of the dot in multi-line method calls.
18
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
19
+ Enabled: true
20
+ EnforcedStyle: trailing
21
+ SupportedStyles:
22
+ - leading
23
+ - trailing
24
+ Style/FileName:
25
+ Description: Use snake_case for source file names.
26
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
27
+ Enabled: false
28
+ Exclude: []
29
+ Style/GuardClause:
30
+ Description: Check for conditionals that can be replaced with guard clauses
31
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
32
+ Enabled: false
33
+ MinBodyLength: 1
34
+ Style/IfUnlessModifier:
35
+ Description: Favor modifier if/unless usage when you have a single-line body.
36
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
37
+ Enabled: false
38
+ MaxLineLength: 80
39
+ Style/OptionHash:
40
+ Description: Don't use option hashes when you can use keyword arguments.
41
+ Enabled: false
42
+ Style/PercentLiteralDelimiters:
43
+ Description: Use `%`-literal delimiters consistently
44
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
45
+ Enabled: false
46
+ PreferredDelimiters:
47
+ "%": "()"
48
+ "%i": "()"
49
+ "%q": "()"
50
+ "%Q": "()"
51
+ "%r": "{}"
52
+ "%s": "()"
53
+ "%w": "()"
54
+ "%W": "()"
55
+ "%x": "()"
56
+ Style/PredicateName:
57
+ Description: Check the names of predicate methods.
58
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
59
+ Enabled: true
60
+ NamePrefix:
61
+ - is_
62
+ - has_
63
+ - have_
64
+ NamePrefixBlacklist:
65
+ - is_
66
+ Exclude:
67
+ - spec/**/*
68
+ Style/RaiseArgs:
69
+ Description: Checks the arguments passed to raise/fail.
70
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
71
+ Enabled: false
72
+ EnforcedStyle: exploded
73
+ SupportedStyles:
74
+ - compact
75
+ - exploded
76
+ Style/SignalException:
77
+ Description: Checks for proper usage of fail and raise.
78
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
79
+ Enabled: false
80
+ EnforcedStyle: semantic
81
+ SupportedStyles:
82
+ - only_raise
83
+ - only_fail
84
+ - semantic
85
+ Style/SingleLineBlockParams:
86
+ Description: Enforces the names of some block params.
87
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
88
+ Enabled: false
89
+ Methods:
90
+ - reduce:
91
+ - a
92
+ - e
93
+ - inject:
94
+ - a
95
+ - e
96
+ Style/SingleLineMethods:
97
+ Description: Avoid single-line methods.
98
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
99
+ Enabled: false
100
+ AllowIfMethodIsEmpty: true
101
+ Style/StringLiterals:
102
+ Description: Checks if uses of quotes match the configured preference.
103
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
104
+ Enabled: true
105
+ EnforcedStyle: double_quotes
106
+ SupportedStyles:
107
+ - single_quotes
108
+ - double_quotes
109
+ Style/StringLiteralsInInterpolation:
110
+ Description: Checks if uses of quotes inside expressions in interpolated strings
111
+ match the configured preference.
112
+ Enabled: true
113
+ EnforcedStyle: single_quotes
114
+ SupportedStyles:
115
+ - single_quotes
116
+ - double_quotes
117
+ Style/TrailingCommaInArguments:
118
+ Description: 'Checks for trailing comma in argument lists.'
119
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
120
+ Enabled: false
121
+ EnforcedStyleForMultiline: no_comma
122
+ SupportedStyles:
123
+ - comma
124
+ - consistent_comma
125
+ - no_comma
126
+ Style/TrailingCommaInLiteral:
127
+ Description: 'Checks for trailing comma in array and hash literals.'
128
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
129
+ Enabled: false
130
+ EnforcedStyleForMultiline: no_comma
131
+ SupportedStyles:
132
+ - comma
133
+ - consistent_comma
134
+ - no_comma
135
+ Metrics/AbcSize:
136
+ Description: A calculated magnitude based on number of assignments, branches, and
137
+ conditions.
138
+ Enabled: false
139
+ Max: 15
140
+ Metrics/ClassLength:
141
+ Description: Avoid classes longer than 100 lines of code.
142
+ Enabled: false
143
+ CountComments: false
144
+ Max: 100
145
+ Metrics/ModuleLength:
146
+ CountComments: false
147
+ Max: 100
148
+ Description: Avoid modules longer than 100 lines of code.
149
+ Enabled: false
150
+ Metrics/CyclomaticComplexity:
151
+ Description: A complexity metric that is strongly correlated to the number of test
152
+ cases needed to validate a method.
153
+ Enabled: false
154
+ Max: 6
155
+ Metrics/MethodLength:
156
+ Description: Avoid methods longer than 10 lines of code.
157
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
158
+ Enabled: false
159
+ CountComments: false
160
+ Max: 10
161
+ Metrics/ParameterLists:
162
+ Description: Avoid parameter lists longer than three or four parameters.
163
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
164
+ Enabled: false
165
+ Max: 5
166
+ CountKeywordArgs: true
167
+ Metrics/PerceivedComplexity:
168
+ Description: A complexity metric geared towards measuring complexity for a human
169
+ reader.
170
+ Enabled: false
171
+ Max: 7
172
+ Lint/AssignmentInCondition:
173
+ Description: Don't use assignment in conditions.
174
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
175
+ Enabled: false
176
+ AllowSafeAssignment: true
177
+ Style/InlineComment:
178
+ Description: Avoid inline comments.
179
+ Enabled: false
180
+ Style/AccessorMethodName:
181
+ Description: Check the naming of accessor methods for get_/set_.
182
+ Enabled: false
183
+ Style/Alias:
184
+ Description: Use alias_method instead of alias.
185
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
186
+ Enabled: false
187
+ Style/Documentation:
188
+ Description: Document classes and non-namespace modules.
189
+ Enabled: false
190
+ Style/DoubleNegation:
191
+ Description: Checks for uses of double negation (!!).
192
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
193
+ Enabled: false
194
+ Style/EachWithObject:
195
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
196
+ Enabled: false
197
+ Style/EmptyLiteral:
198
+ Description: Prefer literals to Array.new/Hash.new/String.new.
199
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
200
+ Enabled: false
201
+ Style/ModuleFunction:
202
+ Description: Checks for usage of `extend self` in modules.
203
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
204
+ Enabled: false
205
+ Style/OneLineConditional:
206
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
207
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
208
+ Enabled: false
209
+ Style/PerlBackrefs:
210
+ Description: Avoid Perl-style regex back references.
211
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
212
+ Enabled: false
213
+ Style/Send:
214
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
215
+ may overlap with existing methods.
216
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
217
+ Enabled: false
218
+ Style/SpecialGlobalVars:
219
+ Description: Avoid Perl-style global variables.
220
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
221
+ Enabled: false
222
+ Style/VariableInterpolation:
223
+ Description: Don't interpolate global, instance and class variables directly in
224
+ strings.
225
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
226
+ Enabled: false
227
+ Style/WhenThen:
228
+ Description: Use when x then ... for one-line cases.
229
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
230
+ Enabled: false
231
+ Lint/EachWithObjectArgument:
232
+ Description: Check for immutable argument given to each_with_object.
233
+ Enabled: true
234
+ Lint/HandleExceptions:
235
+ Description: Don't suppress exception.
236
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
237
+ Enabled: false
238
+ Lint/LiteralInCondition:
239
+ Description: Checks of literals used in conditions.
240
+ Enabled: false
241
+ Lint/LiteralInInterpolation:
242
+ Description: Checks for literals used in interpolation.
243
+ Enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ inherit_from: https://raw.githubusercontent.com/houndci/hound/master/config/style_guides/ruby.yml
2
+ Style/DotPosition:
3
+ Description: Checks the position of the dot in multi-line method calls.
4
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
5
+ Enabled: true
6
+ EnforcedStyle: trailing
7
+ SupportedStyles:
8
+ - leading
9
+ - trailing
10
+ Style/PercentLiteralDelimiters:
11
+ Description: Use `%`-literal delimiters consistently
12
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
13
+ Enabled: false
14
+ PreferredDelimiters:
15
+ "%": "()"
16
+ "%i": "()"
17
+ "%q": "()"
18
+ "%Q": "()"
19
+ "%r": "{}"
20
+ "%s": "()"
21
+ "%w": "()"
22
+ "%W": "()"
23
+ "%x": "()"
24
+ Style/StringLiterals:
25
+ Description: Checks if uses of quotes match the configured preference.
26
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
27
+ Enabled: true
28
+ EnforcedStyle: single_quotes
29
+ SupportedStyles:
30
+ - single_quotes
31
+ - double_quotes
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in diffcop.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Josh Bielick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # DiffCop
2
+
3
+ Run rubocop on the files you've staged in git and only see the offenses on the lines that you've changed or modified. It's like HoundCI, but local.
4
+
5
+ Example Output:
6
+
7
+ `git diff --cached --diff-filter=AM -p`
8
+
9
+ ```
10
+ diff --git a/lib/diff_cop/version.rb b/lib/diff_cop/version.rb
11
+ index ede38dd..e7e71a3 100644
12
+ --- a/lib/diff_cop/version.rb
13
+ +++ b/lib/diff_cop/version.rb
14
+ @@ -1,3 +1,6 @@
15
+ class DiffCop
16
+ - VERSION = '0.1.0'.freeze
17
+ + VERSION = '0.1.0'.freeze
18
+ +
19
+ + def some_method( args)
20
+ + end
21
+ end
22
+ ```
23
+
24
+ And then after running `diffcop`:
25
+
26
+ ```
27
+ DiffCop Offenses:
28
+ =====================
29
+
30
+ lib/diff_cop/version.rb:2:
31
+
32
+ + VERSION = '0.1.0'.freeze
33
+
34
+ Operator `=` should be surrounded by a single space.
35
+ Unnecessary spacing detected.
36
+
37
+
38
+ lib/diff_cop/version.rb:4:
39
+
40
+ + def some_method( args)
41
+
42
+ Space inside parentheses detected.
43
+
44
+
45
+ lib/diff_cop/version.rb:5:
46
+
47
+ + end
48
+
49
+ `end` at 5, 4 is not aligned with `def` at 4, 2.
50
+ ```
51
+
52
+
53
+ ## Installation
54
+
55
+ Add this line to your application's Gemfile:
56
+
57
+ ```ruby
58
+ gem 'diff_cop'
59
+ ```
60
+
61
+ And then execute:
62
+
63
+ $ bundle
64
+
65
+ Or install it yourself as:
66
+
67
+ $ gem install diff_cop
68
+
69
+ ## Usage
70
+
71
+ Stage some files with `git add {files}` and then run `diffcop` in your git root. Rubocop will run only against the file that you've staged and it will only output the offenses on the lines that you've changed or added.
72
+
73
+ This attempts to replicate the behavior of a HoundCI locally so that you can fix your linting offenses before pushing to remote :]
74
+
75
+ ## Development
76
+
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
78
+
79
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
80
+
81
+ ## Tests
82
+
83
+ `rspec`
84
+
85
+ ## Contributing
86
+
87
+ 1. Fork it ( https://github.com/[my-github-username]/diff_cop/fork )
88
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
89
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
90
+ 3.5 Write some passing tests
91
+ 4. Push to the branch (`git push origin my-new-feature`)
92
+ 5. Create a new Pull Request
93
+
94
+ ## HoundCI
95
+
96
+ [always in style](https://houndci.com)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "diff_cop"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/diffcop ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'diff_cop'
4
+
5
+ exit DiffCop.new.start.print! ? 0 : 1
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/diff_cop.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'diff_cop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "diff_cop"
8
+ spec.version = DiffCop::VERSION
9
+ spec.authors = ["Josh Bielick"]
10
+ spec.email = ["jbielick@gmail.com"]
11
+
12
+ spec.summary = %q{Run rubocop only against your modifications `git diff`}
13
+ spec.description = %q{Rubocop is great. Running rubocop on a large file of old code yields tons of violations that are risky and costly to update. This gem allows you to run rubocop only against the files and lines that you've changed/added that show up in `git diff`.}
14
+ spec.homepage = "http://joshbielick.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = ['diffcop']
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_dependency "git_diff_parser"
28
+ spec.add_dependency "rubocop"
29
+ end
data/lib/diff_cop.rb ADDED
@@ -0,0 +1,118 @@
1
+ require 'diff_cop/version'
2
+ require 'git_diff_parser'
3
+ require 'json'
4
+
5
+ class DiffCop
6
+ attr_accessor :patches, :raw_lint_results, :lint_results
7
+
8
+ # generate patches, run the linter and filter to only relevant results
9
+ def start
10
+ @patches = generate_patches.group_by(&:file)
11
+ @raw_lint_results = parsed_raw_lint_results(patches.keys)
12
+ @lint_results = filter_raw_lint_results(
13
+ raw_lint_results['files'] || [],
14
+ patches
15
+ )
16
+
17
+ self
18
+ end
19
+
20
+ # take the generated lint results and print the relevant offenses
21
+ # to stdout (CLI)
22
+ def print!
23
+ fail 'must run #start before printing' unless @lint_results
24
+
25
+ if @lint_results.empty?
26
+ puts "\nYou're good! Rubocop has no offenses to report.\n"
27
+ return true
28
+ end
29
+
30
+ puts <<-MSG
31
+
32
+ DiffCop Offenses:
33
+ =====================
34
+
35
+ #{generate_messages.join("\n\n")}
36
+
37
+ MSG
38
+
39
+ false
40
+ end
41
+
42
+ private
43
+
44
+ # get git diff output for staged files A or M filtered
45
+ # with .rb or .rake extensions
46
+ def diff_output
47
+ `
48
+ git diff \
49
+ --diff-filter=AM \
50
+ --ignore-space-at-eol \
51
+ --no-color \
52
+ --cached \
53
+ -p \
54
+ -- '*.rb' '*.rake'
55
+ `
56
+ end
57
+
58
+ def generate_patches
59
+ GitDiffParser.parse(diff_output)
60
+ end
61
+
62
+ # json-parsed rubocop results
63
+ def parsed_raw_lint_results(files)
64
+ return {} unless files.any?
65
+ JSON.parse(`rubocop -R #{files.join(' ')} --format json`)
66
+ end
67
+
68
+ # get the line content from the patch containing the provided line number
69
+ def get_line_content(patch, line_number)
70
+ patch.
71
+ changed_lines.
72
+ detect { |line| line.number == line_number }.
73
+ instance_variable_get(:@content)
74
+ end
75
+
76
+ # find the patch in the provided list which contains the line number provided
77
+ def find_patch_for_line_number(file_patches, line_number)
78
+ file_patches.detect do |patch|
79
+ patch.changed_line_numbers.include?(line_number)
80
+ end
81
+ end
82
+
83
+ def generate_messages
84
+ @lint_results.flat_map do |(file_path, offenses)|
85
+ offenses.
86
+ group_by { |o| o['location']['line'] }.
87
+ map do |(line_no, line_offenses)|
88
+ line_content = get_line_content(line_offenses.first['patch'], line_no)
89
+ <<-MSG
90
+ #{file_path}:#{line_no}:
91
+
92
+ #{line_content}
93
+ #{line_offenses.map { |o| o['message'] }.join("\n ")}
94
+ MSG
95
+ end
96
+ end
97
+ end
98
+
99
+ # [{
100
+ # path: ...,
101
+ # offenses: []
102
+ # }]
103
+ #
104
+ # []<GitDiffParser::Patch>
105
+ def filter_raw_lint_results(raw_lint_results, all_patches)
106
+ raw_lint_results.inject({}) do |memo, result|
107
+ file_patches = all_patches.fetch(result['path'])
108
+
109
+ relevant_offenses = result['offenses'].select do |offense|
110
+ offense['patch'] =
111
+ find_patch_for_line_number(file_patches, offense['location']['line'])
112
+ end
113
+
114
+ memo[result['path']] = relevant_offenses if relevant_offenses.any?
115
+ memo
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,3 @@
1
+ class DiffCop
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diff_cop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Bielick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: git_diff_parser
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Rubocop is great. Running rubocop on a large file of old code yields
112
+ tons of violations that are risky and costly to update. This gem allows you to run
113
+ rubocop only against the files and lines that you've changed/added that show up
114
+ in `git diff`.
115
+ email:
116
+ - jbielick@gmail.com
117
+ executables:
118
+ - diffcop
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - .gitignore
123
+ - .rspec
124
+ - .rubocop-https---raw-githubusercontent-com-houndci-hound-master-config-style-guides-ruby-yml
125
+ - .rubocop.yml
126
+ - .travis.yml
127
+ - Gemfile
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bin/console
132
+ - bin/diffcop
133
+ - bin/setup
134
+ - diff_cop.gemspec
135
+ - lib/diff_cop.rb
136
+ - lib/diff_cop/version.rb
137
+ homepage: http://joshbielick.com
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.0.14
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Run rubocop only against your modifications `git diff`
161
+ test_files: []