Skip to content

Commit dfd7fd2

Browse files
author
Jack Casey
committed
Fix a large number of style errors.
We have been running with travis automatically fixing errors locally for some time. This has hidden over a thousand style errors in the codebase. Fix the travis config and all the style errors.
1 parent 1cef192 commit dfd7fd2

Some content is hidden

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

72 files changed

+1047
-1048
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gemfile:
1111
- gemfiles/rails_5_graphiti_rails.gemfile
1212
- gemfiles/rails_6_graphiti_rails.gemfile
1313
env:
14-
- COMMAND=standardrb --no-fix --format progress
14+
- COMMAND="standardrb --no-fix --format progress"
1515
- COMMAND=rspec
1616
- COMMAND=rspec APPRAISAL_INITIALIZED=true
1717
matrix:

Guardfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ guard :rspec, cmd: "bundle exec rspec --color --format documentation" do
2121
watch(rails.controllers) do |m|
2222
[
2323
rspec.spec.call("controllers/#{m[1]}_controller"),
24-
rspec.spec.call("api/#{m[1]}"),
24+
rspec.spec.call("api/#{m[1]}")
2525
]
2626
end
2727

2828
# Rails config changes
29-
watch(rails.spec_helper) { rspec.spec_dir }
30-
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
31-
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
29+
watch(rails.spec_helper) { rspec.spec_dir }
30+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
31+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
3232
end

deprecated_generators/graphiti/resource_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def default_attributes
9393
raise "Unable to set #{self} default_attributes from #{attributes_class}. #{attributes_class} must be a kind of ApplicationRecord"
9494
end
9595
if attributes_class.table_exists?
96-
return attributes_class.columns.map do |c|
96+
attributes_class.columns.map do |c|
9797
OpenStruct.new({name: c.name.to_sym, type: c.type})
9898
end
9999
else

graphiti.gemspec

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
33
require "graphiti/version"
44

55
Gem::Specification.new do |spec|
6-
spec.name = "graphiti"
7-
spec.version = Graphiti::VERSION
8-
spec.authors = ["Lee Richmond"]
9-
spec.email = ["[email protected]"]
6+
spec.name = "graphiti"
7+
spec.version = Graphiti::VERSION
8+
spec.authors = ["Lee Richmond"]
9+
spec.email = ["[email protected]"]
1010

11-
spec.summary = "Easily build jsonapi.org-compatible APIs"
12-
spec.homepage = "https://github.com/graphiti-api/graphiti"
13-
spec.license = "MIT"
11+
spec.summary = "Easily build jsonapi.org-compatible APIs"
12+
spec.homepage = "https://github.com/graphiti-api/graphiti"
13+
spec.license = "MIT"
1414

15-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16-
spec.bindir = "exe"
17-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16+
spec.bindir = "exe"
17+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
1818
spec.require_paths = ["lib"]
1919
spec.required_ruby_version = "~> 2.3"
2020

lib/graphiti.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
require "jsonapi/serializable"
1414

1515
module Graphiti
16-
DEPRECATOR = ActiveSupport::Deprecation.new('2.0', 'Graphiti')
16+
DEPRECATOR = ActiveSupport::Deprecation.new("2.0", "Graphiti")
1717

1818
# @api private
1919
def self.context
@@ -33,9 +33,9 @@ def self.with_context(obj, namespace = nil)
3333
ensure
3434
self.context = prior
3535

36-
resources.each { |resource_class|
36+
resources.each do |resource_class|
3737
resource_class.sideloads.values.each(&:clear_resources)
38-
}
38+
end
3939
end
4040

4141
def self.config

lib/graphiti/adapters/abstract.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.sideloading_classes
1717
belongs_to: ::Graphiti::Sideload::BelongsTo,
1818
has_one: ::Graphiti::Sideload::HasOne,
1919
many_to_many: ::Graphiti::Sideload::ManyToMany,
20-
polymorphic_belongs_to: ::Graphiti::Sideload::PolymorphicBelongsTo,
20+
polymorphic_belongs_to: ::Graphiti::Sideload::PolymorphicBelongsTo
2121
}
2222
end
2323

@@ -33,7 +33,7 @@ def self.default_operators
3333
:suffix,
3434
:not_suffix,
3535
:match,
36-
:not_match,
36+
:not_match
3737
],
3838
uuid: [:eq, :not_eq],
3939
enum: [:eq, :not_eq],
@@ -45,7 +45,7 @@ def self.default_operators
4545
date: numerical_operators,
4646
datetime: numerical_operators,
4747
hash: [:eq],
48-
array: [:eq],
48+
array: [:eq]
4949
}
5050
end
5151

lib/graphiti/adapters/active_record.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def self.sideloading_classes
1212
has_many: Graphiti::Adapters::ActiveRecord::HasManySideload,
1313
has_one: Graphiti::Adapters::ActiveRecord::HasOneSideload,
1414
belongs_to: Graphiti::Adapters::ActiveRecord::BelongsToSideload,
15-
many_to_many: Graphiti::Adapters::ActiveRecord::ManyToManySideload,
15+
many_to_many: Graphiti::Adapters::ActiveRecord::ManyToManySideload
1616
}
1717
end
1818

@@ -82,24 +82,24 @@ def filter_string_not_suffix(scope, attribute, value)
8282
# Arel has different match escaping behavior before rails 5.
8383
# Since rails 4.x does not expose methods to escape LIKE statements
8484
# anyway, we just don't support proper LIKE escaping in those versions.
85-
if ::ActiveRecord.version >= Gem::Version.new('5.0.0')
85+
if ::ActiveRecord.version >= Gem::Version.new("5.0.0")
8686
def filter_string_match(scope, attribute, value, is_not: false)
8787
escape_char = '\\'
8888
column = column_for(scope, attribute)
89-
map = value.map do |v|
89+
map = value.map { |v|
9090
v = v.downcase
9191
v = scope.sanitize_sql_like(v)
9292
"%#{v}%"
93-
end
93+
}
9494
clause = column.lower.matches_any(map, escape_char, true)
9595
is_not ? scope.where.not(clause) : scope.where(clause)
9696
end
9797
else
9898
def filter_string_match(scope, attribute, value, is_not: false)
9999
column = column_for(scope, attribute)
100-
map = value.map do |v|
100+
map = value.map { |v|
101101
"%#{v.downcase}%"
102-
end
102+
}
103103
clause = column.lower.matches_any(map)
104104
is_not ? scope.where.not(clause) : scope.where(clause)
105105
end

lib/graphiti/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def initialize
4343
end
4444

4545
if (logger = ::Rails.logger)
46-
self.debug = logger.level.zero? && self.debug
46+
self.debug = logger.level.zero? && debug
4747
Graphiti.logger = logger
4848
end
4949
end

lib/graphiti/debugger.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def on_sideload_data(payload, params, took)
5959
add_chunk(payload[:resource], payload[:parent]) do |logs, json|
6060
logs << [" \\_ #{sideload.name}", :yellow, true]
6161
json[:name] = sideload.name
62-
if sideload.class.scope_proc
63-
query = "#{payload[:resource].class.name}: Manual sideload via .scope"
62+
query = if sideload.class.scope_proc
63+
"#{payload[:resource].class.name}: Manual sideload via .scope"
6464
else
65-
query = "#{payload[:resource].class.name}.all(#{params.inspect})"
65+
"#{payload[:resource].class.name}.all(#{params.inspect})"
6666
end
6767
logs << [" #{query}", :cyan, true]
6868
json[:query] = query
@@ -148,7 +148,7 @@ def add_chunk(resource = nil, parent = nil)
148148
parent: parent,
149149
logs: logs,
150150
json: json,
151-
children: [],
151+
children: []
152152
}
153153
end
154154

lib/graphiti/delegates/pagination.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def links
1515
links[:last] = pagination_link(last_page)
1616
links[:prev] = pagination_link(current_page - 1) unless current_page == 1
1717
links[:next] = pagination_link(current_page + 1) unless current_page == last_page
18-
end.select {|k, v| !v.nil? }
18+
end.select { |k, v| !v.nil? }
1919
end
2020

2121
private
@@ -29,8 +29,8 @@ def pagination_link(page)
2929
uri.query = @proxy.query.hash.merge({
3030
page: {
3131
number: page,
32-
size: page_size,
33-
},
32+
size: page_size
33+
}
3434
}).to_query
3535
uri.to_s
3636
end

0 commit comments

Comments
 (0)