Skip to content

Commit f6536dc

Browse files
committed
Merge pull request shakacode#29 from justin808/rubocop-integration
Added RuboCop Checking. ``` bin/lint ✹ [14:16:35] Linting with Rubocop Inspecting 32 files ................................ 32 files inspected, no offenses detected Linting with ruby-lint /Users/justin/j/react/react-webpack-rails-tutorial/client/node_modules/bootstrap-sass/tasks/converter/less_conversion.rb:W:299:22: ambiguous first argument; put parentheses or a space even after the operator Linting with eslint and jscs > [email protected] jscs /Users/justin/j/react/react-webpack-rails-tutorial/client > jscs --verbose . No code style errors found. ```
2 parents db39174 + e518ea3 commit f6536dc

Some content is hidden

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

42 files changed

+191
-259
lines changed

.rubocop.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This is the configuration used to check the rubocop source code.
2+
3+
AllCops:
4+
Exclude:
5+
- 'vendor/**/*'
6+
- 'spec/fixtures/**/*'
7+
- 'node_modules/**/*'
8+
- 'db/schema.rb'
9+
- 'db/seeds.rb'
10+
- 'client/node_modules/**/*'
11+
- 'bin/**/*'
12+
13+
Metrics/LineLength:
14+
Max: 120
15+
16+
Style/StringLiterals:
17+
EnforcedStyle: double_quotes
18+
19+
Style/Documentation:
20+
Enabled: false

Gemfile

+37-34
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,76 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22
ruby "2.1.5"
33

44
#
5-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
6-
gem 'rails', '~>4.2'
5+
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
6+
gem "rails", "~>4.2"
77
# Use sqlite3 as the database for Active Record
8-
gem 'sqlite3', group: :development
9-
gem 'pg', group: :production
8+
gem "sqlite3", group: :development
9+
gem "pg", group: :production
1010

1111
# Use SCSS for stylesheets
12-
gem 'sass-rails'
13-
gem 'bootstrap-sass', '~> 3.3.1'
12+
gem "sass-rails"
13+
gem "bootstrap-sass", "~> 3.3.1"
1414
# Use Uglifier as compressor for JavaScript assets
15-
gem 'uglifier'
15+
gem "uglifier"
1616
# Use CoffeeScript for .js.coffee assets and views
17-
gem 'coffee-rails'
17+
gem "coffee-rails"
1818
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
19-
# gem 'therubyracer', platforms: :ruby
19+
# gem "therubyracer", platforms: :ruby
2020

2121
# Use jquery as the JavaScript library
22-
gem 'jquery-rails'
22+
gem "jquery-rails"
2323
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
24-
gem 'turbolinks'
24+
gem "turbolinks"
2525
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26-
gem 'jbuilder'
26+
gem "jbuilder"
2727
# bundle exec rake doc:rails generates the API under doc/api.
28-
gem 'sdoc', group: :doc
28+
gem "sdoc", group: :doc
2929

3030
# Use ActiveModel has_secure_password
31-
# gem 'bcrypt', '~> 3.1.7'
31+
# gem "bcrypt", "~> 3.1.7"
3232

3333
# Use Rails Html Sanitizer for HTML sanitization
34-
gem 'rails-html-sanitizer'
34+
gem "rails-html-sanitizer"
3535

3636
# Use Unicorn as the app server
37-
gem 'unicorn'
37+
gem "unicorn"
3838

39-
gem 'autoprefixer-rails'
39+
gem "autoprefixer-rails"
4040

4141
# Use Capistrano for deployment
42-
# gem 'capistrano-rails', group: :development
42+
# gem "capistrano-rails", group: :development
4343
group :production do
44-
gem 'rails_12factor'
44+
gem "rails_12factor"
4545
end
4646

47-
4847
group :development, :test do
49-
# Call 'debugger' anywhere in the code to stop execution and get a debugger console
50-
gem 'byebug'
48+
# Call "debugger" anywhere in the code to stop execution and get a debugger console
49+
gem "byebug"
5150

5251
# Access an IRB console on exceptions page and /console in development
53-
gem 'web-console', '~> 2.0.0.beta2'
52+
gem "web-console", "~> 2.0.0.beta2"
5453

5554
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
56-
gem 'spring'
55+
gem "spring"
5756

5857
# Manage application processes
59-
gem 'foreman'
58+
gem "foreman"
59+
60+
gem "factory_girl_rails"
61+
62+
gem "rubocop", require: false
6063

61-
gem 'factory_girl_rails'
64+
gem "ruby-lint", require: false
6265
end
6366

64-
gem 'spring-commands-rspec', group: :development
67+
gem "spring-commands-rspec", group: :development
6568

6669
group :test do
67-
gem 'rspec-rails'
68-
gem 'capybara'
69-
gem 'capybara-screenshot'
70-
gem 'capybara-webkit'
71-
gem 'database_cleaner'
72-
gem 'launchy'
70+
gem "rspec-rails"
71+
gem "capybara"
72+
gem "capybara-screenshot"
73+
gem "capybara-webkit"
74+
gem "database_cleaner"
75+
gem "launchy"
7376
end

Gemfile.lock

+20
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ GEM
3838
tzinfo (~> 1.1)
3939
addressable (2.3.7)
4040
arel (6.0.0)
41+
ast (2.0.0)
42+
astrolabe (1.3.0)
43+
parser (>= 2.2.0.pre.3, < 3.0)
4144
autoprefixer-rails (5.1.8)
4245
execjs
4346
json
@@ -106,7 +109,10 @@ GEM
106109
multi_json (1.11.0)
107110
nokogiri (1.6.6.2)
108111
mini_portile (~> 0.6.0)
112+
parser (2.2.0.3)
113+
ast (>= 1.1, < 3.0)
109114
pg (0.18.1)
115+
powerpack (0.1.0)
110116
rack (1.6.0)
111117
rack-test (0.6.3)
112118
rack (>= 1.0)
@@ -139,6 +145,7 @@ GEM
139145
activesupport (= 4.2.1)
140146
rake (>= 0.8.7)
141147
thor (>= 0.18.1, < 2.0)
148+
rainbow (2.0.0)
142149
raindrops (0.13.0)
143150
rake (10.4.2)
144151
rdoc (4.2.0)
@@ -160,6 +167,16 @@ GEM
160167
rspec-mocks (~> 3.2.0)
161168
rspec-support (~> 3.2.0)
162169
rspec-support (3.2.2)
170+
rubocop (0.29.1)
171+
astrolabe (~> 1.3)
172+
parser (>= 2.2.0.1, < 3.0)
173+
powerpack (~> 0.1)
174+
rainbow (>= 1.99.1, < 3.0)
175+
ruby-progressbar (~> 1.4)
176+
ruby-lint (2.0.3)
177+
parser (~> 2.1, >= 2.1.1)
178+
slop (~> 3.4, >= 3.4.7)
179+
ruby-progressbar (1.7.5)
163180
sass (3.4.13)
164181
sass-rails (5.0.1)
165182
railties (>= 4.0.0, < 5.0)
@@ -170,6 +187,7 @@ GEM
170187
sdoc (0.4.1)
171188
json (~> 1.7, >= 1.7.7)
172189
rdoc (~> 4.0)
190+
slop (3.6.0)
173191
spring (1.3.3)
174192
spring-commands-rspec (1.0.4)
175193
spring (>= 0.9.1)
@@ -227,6 +245,8 @@ DEPENDENCIES
227245
rails-html-sanitizer
228246
rails_12factor
229247
rspec-rails
248+
rubocop
249+
ruby-lint
230250
sass-rails
231251
sdoc
232252
spring

Rakefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Add your own tasks in files placed in lib/tasks ending in .rake,
22
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
33

4-
require File.expand_path('../config/application', __FILE__)
4+
require File.expand_path("../config/application", __FILE__)
55

66
Rails.application.load_tasks
7+
8+
require "rubocop/rake_task"
9+
10+
RuboCop::RakeTask.new

app/controllers/comments_controller.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def create
2828

2929
respond_to do |format|
3030
if @comment.save
31-
format.html { redirect_to @comment, notice: 'Comment was successfully created.' }
31+
format.html { redirect_to @comment, notice: "Comment was successfully created." }
3232
format.json { render :show, status: :created, location: @comment }
3333
else
3434
format.html { render :new }
@@ -42,7 +42,7 @@ def create
4242
def update
4343
respond_to do |format|
4444
if @comment.update(comment_params)
45-
format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
45+
format.html { redirect_to @comment, notice: "Comment was successfully updated." }
4646
format.json { render :show, status: :ok, location: @comment }
4747
else
4848
format.html { render :edit }
@@ -56,19 +56,20 @@ def update
5656
def destroy
5757
@comment.destroy
5858
respond_to do |format|
59-
format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }
59+
format.html { redirect_to comments_url, notice: "Comment was successfully destroyed." }
6060
format.json { head :no_content }
6161
end
6262
end
6363

6464
private
65-
# Use callbacks to share common setup or constraints between actions.
66-
def set_comment
67-
@comment = Comment.find(params[:id])
68-
end
6965

70-
# Never trust parameters from the scary internet, only allow the white list through.
71-
def comment_params
72-
params.require(:comment).permit(:author, :text)
73-
end
66+
# Use callbacks to share common setup or constraints between actions.
67+
def set_comment
68+
@comment = Comment.find(params[:id])
69+
end
70+
71+
# Never trust parameters from the scary internet, only allow the white list through.
72+
def comment_params
73+
params.require(:comment).permit(:author, :text)
74+
end
7475
end

client/.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ rules:
125125
key-spacing: [2, {beforeColon: false, afterColon: true}]
126126
max-depth: [1, 4]
127127
# Different from 80 chars of AirBnb Javascript
128-
max-len: [2, 100]
128+
max-len: [2, 120]
129129
max-nested-callbacks: [1, 2]
130130
max-params: [1, 4]
131131
max-statements: [0, 10]

client/assets/javascripts/components/CommentBox.jsx

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import FormStore from '../stores/FormStore';
99
import CommentActions from '../actions/CommentActions';
1010
import FormActions from '../actions/FormActions';
1111

12-
// Next line is necessary for exposing React to browser for
13-
// the React Developer Tools: http://facebook.github.io/react/blog/2014/01/02/react-chrome-developer-tools.html
14-
// require("expose?React!react");
15-
1612
var CommentBox = React.createClass({
1713
displayName: 'CommentBox',
1814

client/assets/stylesheets/_bootstrap-variables-customization.scss

-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ $image-url-path: "/assets/images/" !default;
3131
@return url("#{$image-url-path}#{$image}");
3232
}
3333
}
34-
35-
//$image-url-path: "../images/" !default;
36-
//@function image-url($url) {
37-
// @return url("#{$image-url-path}#{$url}");
38-
//}

client/bin/lint

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/sh
22
find . -path ./node_modules -prune -o -name "*.js" -o -name "*.jsx" -exec eslint {} \;
33
npm run jscs .
4-

client/jetbrains/Inspection_RailsOnMaui_Default.xml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<inspection_tool class="JSJQueryEfficiency" enabled="false" level="WARNING" enabled_by_default="false" />
6060
<inspection_tool class="JSUnresolvedLibraryURL" enabled="false" level="WARNING" enabled_by_default="false" />
6161
<inspection_tool class="JSUnusedGlobalSymbols" enabled="false" level="WARNING" enabled_by_default="false" />
62+
<inspection_tool class="Jscs" enabled="true" level="ERROR" enabled_by_default="true" />
6263
<inspection_tool class="LabeledStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
6364
<inspection_tool class="LessResolvedByNameOnly" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
6465
<inspection_tool class="LessUnresolvedMixin" enabled="false" level="WARNING" enabled_by_default="false" />

client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"test": "echo \"Error: no test specified\" && exit 1",
6363
"start": "node server.js",
6464
"gulp": "gulp",
65-
"jscs": "jscs",
65+
"jscs": "jscs --verbose",
6666
"eslint": "eslint"
6767
}
6868
}

config/application.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require File.expand_path('../boot', __FILE__)
1+
require File.expand_path("../boot", __FILE__)
22

3-
require 'rails/all'
3+
require "rails/all"
44

55
# Require the gems listed in Gemfile, including any gems
66
# you've limited to :test, :development, or :production.
@@ -14,16 +14,16 @@ class Application < Rails::Application
1414

1515
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
1616
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17-
# config.time_zone = 'Central Time (US & Canada)'
17+
# config.time_zone = "Central Time (US & Canada)"
1818

1919
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20+
# config.i18n.load_path += Dir[Rails.root.join("my", "locales", "*.{rb,yml}").to_s]
2121
# config.i18n.default_locale = :de
2222

2323
# For not swallow errors in after_commit/after_rollback callbacks.
2424
config.active_record.raise_in_transactional_callbacks = true
2525

2626
# Add client/assets/stylesheets to asset pipeline's search path.
27-
config.assets.paths << Rails.root.join("client", "assets" ,"stylesheets")
27+
config.assets.paths << Rails.root.join("client", "assets", "stylesheets")
2828
end
2929
end

config/boot.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
1+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
22

3-
require 'bundler/setup' # Set up gems listed in the Gemfile.
3+
require "bundler/setup" # Set up gems listed in the Gemfile.

config/database.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# gem install sqlite3
33
#
44
# Ensure the SQLite 3 gem is defined in your Gemfile
5-
# gem 'sqlite3'
5+
# gem "sqlite3"
66
#
77
default: &default
88
adapter: sqlite3

config/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Load the Rails application.
2-
require File.expand_path('../application', __FILE__)
2+
require File.expand_path("../application", __FILE__)
33

44
# Initialize the Rails application.
55
Rails.application.initialize!

config/environments/development.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
config.eager_load = false
1111

1212
# Show full error reports and disable caching.
13-
config.consider_all_requests_local = true
13+
config.consider_all_requests_local = true
1414
config.action_controller.perform_caching = false
1515

1616
# Don't care if the mailer can't send.
@@ -27,7 +27,7 @@
2727
# number of complex assets.
2828
config.assets.debug = true
2929

30-
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
30+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
3131
# yet still be able to expire them through the digest params.
3232
config.assets.digest = true
3333

0 commit comments

Comments
 (0)