Skip to content

Commit

Permalink
basic rubocop setup (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser authored and ddnexus committed May 29, 2018
1 parent 7aee689 commit 7050ee0
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 7 deletions.
14 changes: 14 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,14 @@
Layout:
Enabled: false

Metrics:
Enabled: false

Style:
Enabled: false

Gemspec/OrderedDependencies:
Enabled: false

Naming/UncommunicativeMethodParamName:
Enabled: false
15 changes: 15 additions & 0 deletions Gemfile.lock
Expand Up @@ -13,6 +13,7 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
benchmark-ips (2.7.2)
coffee-script (2.4.1)
coffee-script-source
Expand Down Expand Up @@ -225,18 +226,31 @@ GEM
mini_portile2 (~> 2.3.0)
octokit (4.8.0)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.12.1)
parser (2.5.1.0)
ast (~> 2.4.0)
pathutil (0.16.1)
forwardable-extended (~> 2.6)
powerpack (0.1.1)
public_suffix (2.0.5)
rack (2.0.5)
rainbow (3.0.0)
rake (10.5.0)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rbzip2 (0.2.0)
rouge (2.2.1)
rubocop (0.55.0)
parallel (~> 1.10)
parser (>= 2.5)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-enum (0.7.2)
i18n
ruby-progressbar (1.9.0)
ruby_dep (1.5.0)
rubyzip (1.2.1)
safe_yaml (1.0.4)
Expand Down Expand Up @@ -276,6 +290,7 @@ DEPENDENCIES
pagy!
rack
rake (~> 10.0)
rubocop (~> 0.55.0)
slim

BUNDLED WITH
Expand Down
6 changes: 5 additions & 1 deletion Rakefile
@@ -1,10 +1,14 @@
require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
require "rubocop/rake_task"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end

task :default => :test
RuboCop::RakeTask.new

task :default => [:test, :rubocop]
2 changes: 1 addition & 1 deletion lib/pagy.rb
Expand Up @@ -22,7 +22,7 @@ def self.root; Pathname.new(__FILE__).dirname end

# merge and validate the options, do some simple aritmetic and set the instance variables
def initialize(vars)
@vars = VARS.merge(vars.delete_if{|k,v| v.nil? || v == '' }) # default vars + cleaned instance vars
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned instance vars
{ count:0, items:1, outset:0, page:1 }.each do |k,min| # validate core variables
(@vars[k] && instance_variable_set(:"@#{k}", @vars.delete(k).to_i) >= min) \
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{instance_variable_get(:"@#{k}").inspect}")
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/frontend.rb
Expand Up @@ -74,7 +74,7 @@ def pagy_t(path, vars={})
value.key?(plural) or return %(invalid pluralization data: "#{path}" cannot be used with count: #{vars[:count]}; key "#{plural}" is missing.)
value = value[plural] or return %(translation missing: "#{path}")
end
sprintf value, Hash.new{|h,k| "%{#{k}}"}.merge!(vars) # interpolation
sprintf value, Hash.new{|_,k| "%{#{k}}"}.merge!(vars) # interpolation
end
end

Expand Down
1 change: 1 addition & 0 deletions pagy.gemspec
Expand Up @@ -29,5 +29,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'benchmark-ips'
s.add_development_dependency 'kalibera'
s.add_development_dependency 'memory_profiler'
s.add_development_dependency 'rubocop', '~> 0.55.0' # needs to be fixed since it constantly adds new cops

end
6 changes: 3 additions & 3 deletions test/frontend_test.rb
Expand Up @@ -17,7 +17,7 @@ def setup
end

def test_pagy_nav_page_1
pagy, paged = @array.pagy(1)
pagy, _ = @array.pagy(1)

assert_equal(
'<nav class="pagy-nav pagination" role="navigation" aria-label="pager">' \
Expand All @@ -35,7 +35,7 @@ def test_pagy_nav_page_1
end

def test_pagy_nav_page_3
pagy, paged = @array.pagy(3)
pagy, _ = @array.pagy(3)

assert_equal(
'<nav class="pagy-nav pagination" role="navigation" aria-label="pager">' \
Expand All @@ -53,7 +53,7 @@ def test_pagy_nav_page_3
end

def test_pagy_nav_page_6
pagy, paged = @array.pagy(6)
pagy, _ = @array.pagy(6)

assert_equal(
'<nav class="pagy-nav pagination" role="navigation" aria-label="pager">' \
Expand Down
2 changes: 1 addition & 1 deletion test/i18n_test.rb
Expand Up @@ -7,7 +7,7 @@ class TestI18n;
end

def setup
@I18n = TestI18n.new
@I18n = TestI18n.new # rubocop:disable Naming/VariableName TODO rename
end

def test_data
Expand Down

0 comments on commit 7050ee0

Please sign in to comment.