scold 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +2 -0
- data/README.md +25 -0
- data/bin/hound +4 -0
- data/bin/scold +4 -0
- data/lib/scold/exit.rb +6 -0
- data/lib/scold/hound.yml +1068 -0
- data/lib/scold/hounder.rb +28 -0
- data/lib/scold/scolder.rb +47 -0
- data/lib/scold/version.rb +3 -0
- data/lib/scold.rb +2 -0
- data/scold.gemspec +31 -0
- data/spec/fixtures/custom/.rubocop.yml +3 -0
- data/spec/fixtures/custom/c140.rb +1 -0
- data/spec/fixtures/custom/c90.rb +1 -0
- data/spec/fixtures/simple/c140.rb +1 -0
- data/spec/fixtures/simple/c90.rb +1 -0
- data/spec/hounder_spec.rb +7 -0
- data/spec/scolder_spec.rb +33 -0
- metadata +114 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
module Scold
|
2
|
+
class Hounder
|
3
|
+
CHANGED = %w(M A R C).freeze
|
4
|
+
|
5
|
+
def initialize(args = [])
|
6
|
+
@args = args.dup
|
7
|
+
end
|
8
|
+
|
9
|
+
def call # rubocop:disable Metrics/AbcSize
|
10
|
+
files = `git status --porcelain`.lines.inject([]) do |accum, line|
|
11
|
+
if CHANGED.include?(line[0]) || CHANGED.include?(line[1])
|
12
|
+
accum << line[3..-1].split("->").last.strip
|
13
|
+
end
|
14
|
+
accum
|
15
|
+
end
|
16
|
+
if files.empty?
|
17
|
+
require "scold/exit"
|
18
|
+
Exit::SUCCESS
|
19
|
+
else
|
20
|
+
Scolder.run(@args.concat(files))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(args = [])
|
25
|
+
new(args).call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "scold/exit"
|
2
|
+
|
3
|
+
module Scold
|
4
|
+
class Scolder
|
5
|
+
DEFAULT_CFG_NAME = ".rubocop.yml"
|
6
|
+
|
7
|
+
def initialize(args = [])
|
8
|
+
@args = args.dup
|
9
|
+
end
|
10
|
+
|
11
|
+
def call # rubocop:disable Metrics/AbcSize
|
12
|
+
err = Exit::FAILURE
|
13
|
+
cfg_hound = File.expand_path("../hound.yml", __FILE__)
|
14
|
+
cfg_current = File.expand_path(DEFAULT_CFG_NAME, Dir.pwd)
|
15
|
+
cfg_strict =
|
16
|
+
unless ENV["SCOLD_NO_STRICT"]
|
17
|
+
File.expand_path(".rubocop_strict.yml", Dir.home)
|
18
|
+
end
|
19
|
+
|
20
|
+
require "tempfile"
|
21
|
+
cfg = Tempfile.new("rubocop-scold-")
|
22
|
+
begin
|
23
|
+
cfg << "inherit_from:\n"
|
24
|
+
cfg << " - #{cfg_hound}\n"
|
25
|
+
cfg << " - #{cfg_current}\n" if file?(cfg_current)
|
26
|
+
cfg << " - #{cfg_strict}\n" if file?(cfg_strict)
|
27
|
+
cfg.close
|
28
|
+
args = %W(-c #{cfg.path}).concat(@args)
|
29
|
+
require "rubocop"
|
30
|
+
err = RuboCop::CLI.new.run(args)
|
31
|
+
ensure
|
32
|
+
cfg.close!
|
33
|
+
end
|
34
|
+
err
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.run(args = [])
|
38
|
+
new(args).call
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def file?(value)
|
44
|
+
value && File.file?(value)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/scold.rb
ADDED
data/scold.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "scold/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "scold"
|
6
|
+
s.version = Scold::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.license = "MIT"
|
9
|
+
s.required_ruby_version = ">= 2.1.0"
|
10
|
+
s.authors = ["John Fearnside"]
|
11
|
+
s.summary = "Hound-like Rubocop utility"
|
12
|
+
s.description = "#{s.summary}."
|
13
|
+
s.email = "john@apptentive.com"
|
14
|
+
s.homepage = "https://github.com/apptentive/scold"
|
15
|
+
s.files = `git ls-files`.split($RS) do |file|
|
16
|
+
file =~ %r{^(?:
|
17
|
+
spec/.*
|
18
|
+
|Gemfile
|
19
|
+
|\.rspec
|
20
|
+
|\.gitignore
|
21
|
+
)$}x
|
22
|
+
end
|
23
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
25
|
+
s.require_paths = %w(lib)
|
26
|
+
s.extra_rdoc_files = %w(README.md)
|
27
|
+
s.rubygems_version = "2.4.8"
|
28
|
+
s.add_runtime_dependency("rubocop", "~> 0.33")
|
29
|
+
s.add_development_dependency("bundler", "~> 1.10")
|
30
|
+
s.add_development_dependency("rspec", "~> 3.3")
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# ......10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140
|
@@ -0,0 +1 @@
|
|
1
|
+
# ......10........20........30........40........50........60........70........80........90
|
@@ -0,0 +1 @@
|
|
1
|
+
# ......10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140
|
@@ -0,0 +1 @@
|
|
1
|
+
# ......10........20........30........40........50........60........70........80........90
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "../lib/scold.rb"
|
2
|
+
|
3
|
+
RSpec.describe Scold::Scolder do
|
4
|
+
def cd(d, &_blk_required)
|
5
|
+
Dir.chdir(File.expand_path("../#{d}", __FILE__)) { yield }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".run" do
|
9
|
+
before do
|
10
|
+
stub_const("ENV", ENV.to_hash.merge("SCOLD_NO_STRICT" => "1"))
|
11
|
+
end
|
12
|
+
|
13
|
+
context "without custom .rubocop.yml" do
|
14
|
+
around(:example) { |ex| cd("fixtures/simple") { ex.run } }
|
15
|
+
|
16
|
+
it "rejects lines longer than 80 characters" do
|
17
|
+
expect(described_class.run(%w(c90.rb))).not_to be 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with custom .rubocop.yml" do
|
22
|
+
around(:example) { |ex| cd("fixtures/custom") { ex.run } }
|
23
|
+
|
24
|
+
it "accepts lines shorter than 132 characters" do
|
25
|
+
expect(described_class.run(%w(c90.rb))).to be 0
|
26
|
+
end
|
27
|
+
|
28
|
+
it "rejects lines longer than 132 characters" do
|
29
|
+
expect(described_class.run(%w(c140.rb))).not_to be 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Fearnside
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.33'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.33'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
description: Hound-like Rubocop utility.
|
56
|
+
email: john@apptentive.com
|
57
|
+
executables:
|
58
|
+
- hound
|
59
|
+
- scold
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README.md
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- bin/hound
|
68
|
+
- bin/scold
|
69
|
+
- lib/scold.rb
|
70
|
+
- lib/scold/exit.rb
|
71
|
+
- lib/scold/hound.yml
|
72
|
+
- lib/scold/hounder.rb
|
73
|
+
- lib/scold/scolder.rb
|
74
|
+
- lib/scold/version.rb
|
75
|
+
- scold.gemspec
|
76
|
+
- spec/fixtures/custom/.rubocop.yml
|
77
|
+
- spec/fixtures/custom/c140.rb
|
78
|
+
- spec/fixtures/custom/c90.rb
|
79
|
+
- spec/fixtures/simple/c140.rb
|
80
|
+
- spec/fixtures/simple/c90.rb
|
81
|
+
- spec/hounder_spec.rb
|
82
|
+
- spec/scolder_spec.rb
|
83
|
+
homepage: https://github.com/apptentive/scold
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.1.0
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.5.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Hound-like Rubocop utility
|
107
|
+
test_files:
|
108
|
+
- spec/fixtures/custom/.rubocop.yml
|
109
|
+
- spec/fixtures/custom/c140.rb
|
110
|
+
- spec/fixtures/custom/c90.rb
|
111
|
+
- spec/fixtures/simple/c140.rb
|
112
|
+
- spec/fixtures/simple/c90.rb
|
113
|
+
- spec/hounder_spec.rb
|
114
|
+
- spec/scolder_spec.rb
|