Skip to content

Commit 4accda8

Browse files
committed
Follow the same style guide as Rails
1 parent db78e49 commit 4accda8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1515
-1195
lines changed
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
AllCops:
2+
TargetRubyVersion: 2.4
3+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4+
# to ignore them, so only the ones explicitly set in this file are enabled.
5+
DisabledByDefault: true
6+
Exclude:
7+
- '**/templates/**/*'
8+
- '**/vendor/**/*'
9+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
10+
- 'railties/test/fixtures/tmp/**/*'
11+
- 'node_modules/**/*'
12+
13+
Performance:
14+
Exclude:
15+
- '**/test/**/*'
16+
17+
Rails:
18+
Enabled: true
19+
20+
# Prefer assert_not over assert !
21+
Rails/AssertNot:
22+
Include:
23+
- '**/test/**/*'
24+
25+
# Prefer assert_not_x over refute_x
26+
Rails/RefuteMethods:
27+
Include:
28+
- '**/test/**/*'
29+
30+
# Prefer &&/|| over and/or.
31+
Style/AndOr:
32+
Enabled: true
33+
34+
# Do not use braces for hash literals when they are the last argument of a
35+
# method call.
36+
Style/BracesAroundHashParameters:
37+
Enabled: true
38+
EnforcedStyle: context_dependent
39+
40+
# Align `when` with `case`.
41+
Layout/CaseIndentation:
42+
Enabled: true
43+
44+
# Align comments with method definitions.
45+
Layout/CommentIndentation:
46+
Enabled: true
47+
48+
Layout/ElseAlignment:
49+
Enabled: true
50+
51+
# Align `end` with the matching keyword or starting expression except for
52+
# assignments, where it should be aligned with the LHS.
53+
Layout/EndAlignment:
54+
Enabled: true
55+
EnforcedStyleAlignWith: variable
56+
AutoCorrect: true
57+
58+
Layout/EmptyLineAfterMagicComment:
59+
Enabled: true
60+
61+
Layout/EmptyLinesAroundBlockBody:
62+
Enabled: true
63+
64+
# In a regular class definition, no empty lines around the body.
65+
Layout/EmptyLinesAroundClassBody:
66+
Enabled: true
67+
68+
# In a regular method definition, no empty lines around the body.
69+
Layout/EmptyLinesAroundMethodBody:
70+
Enabled: true
71+
72+
# In a regular module definition, no empty lines around the body.
73+
Layout/EmptyLinesAroundModuleBody:
74+
Enabled: true
75+
76+
Layout/FirstParameterIndentation:
77+
Enabled: true
78+
79+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
80+
Style/HashSyntax:
81+
Enabled: true
82+
83+
# Method definitions after `private` or `protected` isolated calls need one
84+
# extra level of indentation.
85+
Layout/IndentationConsistency:
86+
Enabled: true
87+
EnforcedStyle: rails
88+
89+
# Two spaces, no tabs (for indentation).
90+
Layout/IndentationWidth:
91+
Enabled: true
92+
93+
Layout/LeadingCommentSpace:
94+
Enabled: true
95+
96+
Layout/SpaceAfterColon:
97+
Enabled: true
98+
99+
Layout/SpaceAfterComma:
100+
Enabled: true
101+
102+
Layout/SpaceAroundEqualsInParameterDefault:
103+
Enabled: true
104+
105+
Layout/SpaceAroundKeyword:
106+
Enabled: true
107+
108+
Layout/SpaceAroundOperators:
109+
Enabled: true
110+
111+
Layout/SpaceBeforeComma:
112+
Enabled: true
113+
114+
Layout/SpaceBeforeFirstArg:
115+
Enabled: true
116+
117+
Style/DefWithParentheses:
118+
Enabled: true
119+
120+
# Defining a method with parameters needs parentheses.
121+
Style/MethodDefParentheses:
122+
Enabled: true
123+
124+
Style/FrozenStringLiteralComment:
125+
Enabled: true
126+
EnforcedStyle: always
127+
Exclude:
128+
- 'actionview/test/**/*.builder'
129+
- 'actionview/test/**/*.ruby'
130+
- 'actionpack/test/**/*.builder'
131+
- 'actionpack/test/**/*.ruby'
132+
- 'activestorage/db/migrate/**/*.rb'
133+
134+
Style/RedundantFreeze:
135+
Enabled: true
136+
Exclude:
137+
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
138+
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
139+
140+
# Use `foo {}` not `foo{}`.
141+
Layout/SpaceBeforeBlockBraces:
142+
Enabled: true
143+
144+
# Use `foo { bar }` not `foo {bar}`.
145+
Layout/SpaceInsideBlockBraces:
146+
Enabled: true
147+
EnforcedStyleForEmptyBraces: space
148+
149+
# Use `{ a: 1 }` not `{a:1}`.
150+
Layout/SpaceInsideHashLiteralBraces:
151+
Enabled: true
152+
153+
Layout/SpaceInsideParens:
154+
Enabled: true
155+
156+
# Check quotes usage according to lint rule below.
157+
Style/StringLiterals:
158+
Enabled: true
159+
EnforcedStyle: double_quotes
160+
161+
# Detect hard tabs, no hard tabs.
162+
Layout/Tab:
163+
Enabled: true
164+
165+
# Blank lines should not have any spaces.
166+
Layout/TrailingBlankLines:
167+
Enabled: true
168+
169+
# No trailing whitespace.
170+
Layout/TrailingWhitespace:
171+
Enabled: true
172+
173+
# Use quotes for string literals when they are enough.
174+
Style/UnneededPercentQ:
175+
Enabled: true
176+
177+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
178+
Lint/RequireParentheses:
179+
Enabled: true
180+
181+
Lint/StringConversionInInterpolation:
182+
Enabled: true
183+
184+
Lint/UriEscapeUnescape:
185+
Enabled: true
186+
187+
Style/ParenthesesAroundCondition:
188+
Enabled: true
189+
190+
Style/RedundantReturn:
191+
Enabled: true
192+
AllowMultipleReturnValues: true
193+
194+
Style/Semicolon:
195+
Enabled: true
196+
AllowAsExpressionSeparator: true
197+
198+
# Prefer Foo.method over Foo::method
199+
Style/ColonMethodCall:
200+
Enabled: true
201+
202+
Style/TrivialAccessors:
203+
Enabled: true
204+
205+
Performance/FlatMap:
206+
Enabled: true
207+
208+
Performance/RedundantMerge:
209+
Enabled: true
210+
211+
Performance/StartWith:
212+
Enabled: true
213+
214+
Performance/EndWith:
215+
Enabled: true
216+
217+
Performance/RegexpMatch:
218+
Enabled: true
219+
220+
Performance/UnfreezeString:
221+
Enabled: true

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
inherit_from: https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml
2+
3+
AllCops:
4+
TargetRubyVersion: 2.2
5+
DisabledByDefault: true

Gemfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
source 'https://rubygems.org'
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
24

35
git_source(:github) { |repo| "https://github.com/#{repo}" }
46

5-
branch = ENV.fetch('BRANCH', 'master')
6-
gem 'activesupport', github: 'rails/rails', branch: branch
7-
gem 'activemodel', github: 'rails/rails', branch: branch
8-
gem 'activejob', github: 'rails/rails', branch: branch
7+
branch = ENV.fetch("BRANCH", "master")
8+
gem "activesupport", github: "rails/rails", branch: branch
9+
gem "activemodel", github: "rails/rails", branch: branch
10+
gem "activejob", github: "rails/rails", branch: branch
911

1012
gemspec
1113

1214
platform :mri do
1315
group :test do
14-
gem 'ruby-prof'
16+
gem "ruby-prof"
1517
end
1618
end

Rakefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
#!/usr/bin/env rake
2-
require 'rake/testtask'
3-
require 'bundler'
2+
# frozen_string_literal: true
3+
4+
require "rake/testtask"
5+
require "bundler"
46
Bundler::GemHelper.install_tasks
57

68
desc "Default Task"
7-
task :default => [ :test ]
9+
task default: [ :test ]
810

911
# Run the unit tests
1012

1113
Rake::TestTask.new { |t|
1214
t.libs << "test"
13-
t.pattern = 'test/**/*_test.rb'
15+
t.pattern = "test/**/*_test.rb"
1416
t.warning = true
1517
t.verbose = true
1618
}
1719

1820
namespace :test do
1921
task :isolated do
20-
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
22+
ruby = File.join(*RbConfig::CONFIG.values_at("bindir", "RUBY_INSTALL_NAME"))
2123
activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib"
2224
Dir.glob("test/**/*_test.rb").all? do |file|
23-
sh(ruby, '-w', "-Ilib:test:#{activesupport_path}", file)
24-
end or raise "Failures"
25+
sh(ruby, "-w", "-Ilib:test:#{activesupport_path}", file)
26+
end || raise("Failures")
2527
end
2628
end
2729

activeresource.gemspec

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
# frozen_string_literal: true
2+
13
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
2-
require 'active_resource/version'
4+
require "active_resource/version"
35

46
Gem::Specification.new do |s|
57
s.platform = Gem::Platform::RUBY
6-
s.name = 'activeresource'
8+
s.name = "activeresource"
79
s.version = ActiveResource::VERSION::STRING
8-
s.summary = 'REST modeling framework (part of Rails).'
9-
s.description = 'REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.'
10-
s.license = 'MIT'
10+
s.summary = "REST modeling framework (part of Rails)."
11+
s.description = "REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models."
12+
s.license = "MIT"
1113

12-
s.author = 'David Heinemeier Hansson'
13-
s.email = '[email protected]'
14-
s.homepage = 'http://www.rubyonrails.org'
14+
s.author = "David Heinemeier Hansson"
15+
s.email = "[email protected]"
16+
s.homepage = "http://www.rubyonrails.org"
1517

16-
s.files = Dir['MIT-LICENSE', 'README.rdoc', 'lib/**/*']
17-
s.require_path = 'lib'
18+
s.files = Dir["MIT-LICENSE", "README.rdoc", "lib/**/*"]
19+
s.require_path = "lib"
1820

1921
s.extra_rdoc_files = %w( README.rdoc )
20-
s.rdoc_options.concat ['--main', 'README.rdoc']
22+
s.rdoc_options.concat ["--main", "README.rdoc"]
2123

22-
s.required_ruby_version = '>= 2.2.2'
24+
s.required_ruby_version = ">= 2.2.2"
2325

24-
s.add_dependency('activesupport', '>= 5.0', '< 7')
25-
s.add_dependency('activemodel', '>= 5.0', '< 7')
26-
s.add_dependency('activemodel-serializers-xml', '~> 1.0')
26+
s.add_dependency("activesupport", ">= 5.0", "< 7")
27+
s.add_dependency("activemodel", ">= 5.0", "< 7")
28+
s.add_dependency("activemodel-serializers-xml", "~> 1.0")
2729

28-
s.add_development_dependency('rake')
29-
s.add_development_dependency('mocha', '>= 0.13.0')
30+
s.add_development_dependency("rake")
31+
s.add_development_dependency("mocha", ">= 0.13.0")
3032
end

0 commit comments

Comments
 (0)