Skip to content

Commit

Permalink
Adding rubocop and fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Jan 14, 2016
1 parent 3340f51 commit b0e0a08
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 56 deletions.
120 changes: 120 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
require: rubocop-rspec

AllCops:
RunRailsCops: true
DisplayCopNames: true
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'script/**/*'
- 'vendor/**/*'
- 'bin/*'

Lint/UnusedBlockArgument:
Exclude:
- 'spec/**/*'

Metrics/LineLength:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/ClassLength:
Exclude:
- 'app/controllers/catalog_controller.rb'

Metrics/MethodLength:
Enabled: false

Style/BlockDelimiters:
Exclude:
- 'spec/**/*'

Style/SymbolProc:
Exclude:
- 'spec/factories/**/*'

Style/BlockComments:
Exclude:
- 'spec/spec_helper.rb'

Style/BlockEndNewline:
Exclude:
- 'spec/**/*'

Style/IndentHash:
Exclude:
- 'app/controllers/catalog_controller.rb'

Style/LeadingCommentSpace:
Exclude:
- 'spec/**/*'

Style/MultilineBlockLayout:
Exclude:
- 'spec/**/*'


Style/IndentationConsistency:
EnforcedStyle: rails

Style/CollectionMethods:
PreferredMethods:
collect: 'map'
collect!: 'map!'
inject: 'reduce'
detect: 'find'
find_all: 'select'

Style/WordArray:
Enabled: false

Style/RegexpLiteral:
Enabled: false

Style/StringLiterals:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Style/SingleLineBlockParams:
Enabled: false

Style/SignalException:
Enabled: false

Rails/Date:
Enabled: false

Rails/TimeZone:
Enabled: false

RSpec/ExampleWording:
CustomTransform:
be: is
have: has
not: does not
NOT: does NOT
IgnoredWords:
- only

RSpec/FilePath:
Enabled: false

RSpec/InstanceVariable:
Enabled: false

RSpec/DescribeClass:
Exclude:
- 'spec/abilities/**/*'
- 'spec/features/**/*'
- 'spec/views/**/*'
- 'spec/routing/**/*'
- 'spec/inputs/**/*'
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ gem 'blacklight-gallery', '>= 0.3.0'
gem 'blacklight-oembed'
gem 'social-share-button'
gem 'devise_invitable'
gem 'rubocop', require: false
gem 'rubocop-rspec', require: false
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ GEM
activerecord (>= 3.2, < 5)
addressable (2.4.0)
arel (6.0.3)
ast (2.2.0)
astrolabe (1.3.1)
parser (~> 2.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
Expand Down Expand Up @@ -256,6 +259,9 @@ GEM
activerecord (>= 3.0, < 6.0)
activesupport (>= 3.0, < 6.0)
request_store (~> 1.1)
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand Down Expand Up @@ -289,6 +295,7 @@ GEM
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.4.2)
rdoc (4.2.1)
json (~> 1.4)
Expand Down Expand Up @@ -331,7 +338,16 @@ GEM
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.35.1)
astrolabe (~> 1.3)
parser (>= 2.2.3.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
rubocop-rspec (1.3.1)
ruby-oembed (0.9.0)
ruby-progressbar (1.7.5)
rubyzip (1.1.7)
sass (3.4.20)
sass-rails (5.0.4)
Expand Down Expand Up @@ -427,6 +443,8 @@ DEPENDENCIES
rails (= 4.2.5)
rsolr (~> 1.0.6)
rspec-rails
rubocop
rubocop-rspec
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simplecov (~> 0.9)
Expand Down
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rubocop/rake_task'

Rails.application.load_tasks

ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip"
require 'jettywrapper'

desc 'Run style checker'
RuboCop::RakeTask.new(:rubocop) do |task|
task.requires << 'rubocop-rspec'
task.fail_on_error = true
end
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationController < ActionController::Base
helper Openseadragon::OpenseadragonHelper
# Adds a few additional behaviors into the application controller
# Adds a few additional behaviors into the application controller
include Blacklight::Controller
include Spotlight::Controller

Expand Down
16 changes: 8 additions & 8 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class CatalogController < ApplicationController
include Blacklight::Catalog

configure_blacklight do |config|
config.show.oembed_field = :oembed_url_ssm
config.show.partials.insert(1, :oembed)
config.view.gallery.partials = [:index_header, :index]
config.view.masonry.partials = [:index]
config.view.slideshow.partials = [:index]

config.show.tile_source_field = :content_metadata_image_iiif_info_ssm
config.show.partials.insert(1, :openseadragon)
config.show.oembed_field = :oembed_url_ssm
config.show.partials.insert(1, :oembed)
config.view.gallery.partials = [:index_header, :index]
config.view.masonry.partials = [:index]
config.view.slideshow.partials = [:index]

config.show.tile_source_field = :content_metadata_image_iiif_info_ssm
config.show.partials.insert(1, :openseadragon)

## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
config.default_solr_params = {
Expand Down
17 changes: 6 additions & 11 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
# -*- encoding : utf-8 -*-
class SolrDocument

class SolrDocument
include Blacklight::Solr::Document
include Blacklight::Gallery::OpenseadragonSolrDocument

include Spotlight::SolrDocument

include Spotlight::SolrDocument::AtomicUpdates


# self.unique_key = 'id'

# Email uses the semantic field mappings below to generate the body of an email.
SolrDocument.use_extension( Blacklight::Document::Email )
SolrDocument.use_extension(Blacklight::Document::Email)

# SMS uses the semantic field mappings below to generate the body of an SMS email.
SolrDocument.use_extension( Blacklight::Document::Sms )
SolrDocument.use_extension(Blacklight::Document::Sms)

# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
# Semantic mappings of solr stored fields. Fields may be multi or
# single valued. See Blacklight::Document::SemanticFields#field_semantics
# and Blacklight::Document::SemanticFields#to_semantic_values
# Recommendation: Use field names from Dublin Core
use_extension( Blacklight::Document::DublinCore)

use_extension(Blacklight::Document::DublinCore)
end
5 changes: 3 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class User < ActiveRecord::Base
include Spotlight::User
if Blacklight::Utils.needs_attr_accessible?

attr_accessible :email, :password, :password_confirmation
end
# Connects this user object to Blacklights Bookmarks.

# Connects this user object to Blacklights Bookmarks.
include Blacklight::User

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :invitable, :database_authenticatable, :registerable,
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ dependencies:
- bin/jetty_wait
test:
pre:
# - bundle exec rake rubocop
- bundle exec rake rubocop
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

module Pomegranate
class Application < Rails::Application
config.action_mailer.default_url_options = { host: "localhost:3000", from: "noreply@example.com" }
config.action_mailer.default_url_options = { host: "localhost:3000", from: "noreply@example.com" }

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down
1 change: 0 additions & 1 deletion config/initializers/blacklight_initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
#

# Blacklight.secret_key = '99d542f85bffaadb98670ae96ff5f860c910ede7fb262d48c345ff9d06d7d21ff5533bb8a26934f7067a24b2510f590d25bc6765c9cb02d56ec1e2c83dc78168'

2 changes: 1 addition & 1 deletion config/initializers/friendly_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
config.use :reserved

config.reserved_words = %w(new edit index session login logout users admin
stylesheets assets javascripts images)
stylesheets assets javascripts images)

# ## Friendly Finders
#
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/oembed_providers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require 'oembed'

OEmbed::Providers.register_all
OEmbed::Providers.register_all
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mount Blacklight::Oembed::Engine, at: 'oembed'
root to: 'spotlight/exhibits#index'
mount Spotlight::Engine, at: 'spotlight'
# root to: "catalog#index" # replaced by spotlight root path
# root to: "catalog#index" # replaced by spotlight root path
blacklight_for :catalog
devise_for :users
# The priority is based upon order of creation: first created -> highest priority.
Expand Down
Empty file removed test/controllers/.keep
Empty file.
Empty file removed test/fixtures/.keep
Empty file.
11 changes: 0 additions & 11 deletions test/fixtures/users.yml

This file was deleted.

Empty file removed test/helpers/.keep
Empty file.
Empty file removed test/integration/.keep
Empty file.
Empty file removed test/mailers/.keep
Empty file.
Empty file removed test/models/.keep
Empty file.
7 changes: 0 additions & 7 deletions test/models/user_test.rb

This file was deleted.

10 changes: 0 additions & 10 deletions test/test_helper.rb

This file was deleted.

0 comments on commit b0e0a08

Please sign in to comment.