From cd40b4a48a19a50a37d9e3b1c2a0e7fdd285c098 Mon Sep 17 00:00:00 2001 From: David Kinzer Date: Tue, 17 Sep 2019 15:02:21 -0400 Subject: [PATCH] Update travis. * Add more rubies. * Do not pin bundler. * Add rubocop config from tul_cob (keep standards the same across projects) --- .rubocop.yml | 139 +++++++++++++++++++++++++++++++++++ .travis.yml | 10 ++- Gemfile | 4 +- Gemfile.lock | 2 +- Rakefile | 4 +- cob_web_index.gemspec | 5 +- lib/cob_web_index.rb | 2 +- lib/cob_web_index/version.rb | 2 + spec/cob_web_index_spec.rb | 2 + spec/spec_helper.rb | 2 + 10 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d086002 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,139 @@ +AllCops: + TargetRubyVersion: 2.4 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - 'node_modules/**/*' + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + - 'bin/*' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Do not use braces for hash literals when they are the last argument of a +# method call. +Style/BracesAroundHashParameters: + Enabled: true + EnforcedStyle: context_dependent + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/IndentFirstArgument: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: true + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always + Exclude: + - 'app/models/traject_indexer.rb' + - 'db/schema.rb' + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +# Detect hard tabs, no hard tabs. +Layout/Tab: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingBlankLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: true + +# Use quotes for string literals when they are enough. +Style/UnneededPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Rails: + Enabled: true diff --git a/.travis.yml b/.travis.yml index 9194543..0a79512 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,11 @@ --- sudo: false language: ruby -cache: bundler rvm: - - 2.4.1 -before_install: gem install bundler -v 1.16.6 + - 2.4 + - 2.5 + - 2.6 + +script: + - bundle exec rake + - bundle exec rubocop diff --git a/Gemfile b/Gemfile index 6c1b689..7c420b5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ +# frozen_string_literal: true + source "https://rubygems.org" -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in cob_web_index.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 5e0b1dd..a6c3875 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,7 @@ PLATFORMS DEPENDENCIES binding_of_caller (~> 0.7) - bundler (~> 1.16) + bundler (>= 1.16) cob_web_index! coveralls guard (~> 2.14) diff --git a/Rakefile b/Rakefile index b7e9ed5..b6ae734 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec diff --git a/cob_web_index.gemspec b/cob_web_index.gemspec index 43f19bd..70f8e50 100644 --- a/cob_web_index.gemspec +++ b/cob_web_index.gemspec @@ -1,3 +1,4 @@ +# frozen_string_literal: true lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) @@ -27,7 +28,7 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = "exe" @@ -40,7 +41,7 @@ Gem::Specification.new do |spec| spec.add_dependency "httparty" spec.add_runtime_dependency("gli", "~> 2.18") - spec.add_development_dependency "bundler", "~> 1.16" + spec.add_development_dependency "bundler", ">= 1.16" spec.add_development_dependency "rake", "~> 12.3" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rubocop", "~> 0.52" diff --git a/lib/cob_web_index.rb b/lib/cob_web_index.rb index f836e1e..aa481ff 100644 --- a/lib/cob_web_index.rb +++ b/lib/cob_web_index.rb @@ -44,7 +44,7 @@ def self.pull end def self.open_read(url) - if ENV["WEB_CONTENT_BASIC_AUTH_USER"] && ENV["WEB_CONTENT_BASIC_AUTH_PASSWORD"] + if ENV["WEB_CONTENT_BASIC_AUTH_USER"] && ENV["WEB_CONTENT_BASIC_AUTH_PASSWORD"] user = ENV["WEB_CONTENT_BASIC_AUTH_USER"] password = ENV["WEB_CONTENT_BASIC_AUTH_PASSWORD"] open(url, http_basic_authentication: [user, password]).read diff --git a/lib/cob_web_index/version.rb b/lib/cob_web_index/version.rb index 9d6e072..47a9cd2 100644 --- a/lib/cob_web_index/version.rb +++ b/lib/cob_web_index/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CobWebIndex VERSION = "0.1.0" end diff --git a/spec/cob_web_index_spec.rb b/spec/cob_web_index_spec.rb index 0fdede4..8ed535d 100644 --- a/spec/cob_web_index_spec.rb +++ b/spec/cob_web_index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe CobWebIndex do let(:indexer) { indexer = Traject::Indexer::MarcIndexer.new diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dbc75e9..7f04d7b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/setup" require "cob_web_index"