Skip to content

Commit

Permalink
Install rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecav84 committed Dec 14, 2018
1 parent af169da commit 4ba0ace
Show file tree
Hide file tree
Showing 29 changed files with 274 additions and 191 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
102 changes: 102 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,102 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-12-14 00:26:03 -0500 using RuboCop version 0.61.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'tasks/converter.rb'

# Offense count: 3
Lint/UselessAssignment:
Exclude:
- 'tasks/converter.rb'

# Offense count: 4
Metrics/AbcSize:
Max: 23

# Offense count: 4
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 36

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 114

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 7

# Offense count: 3
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 14

# Offense count: 1
Metrics/PerceivedComplexity:
Max: 8

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'tasks/converter.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/fomantic-ui-sass.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'tasks/converter.rb'

# Offense count: 1
Security/Eval:
Exclude:
- 'lib/fomantic/ui/sass/breadcrumbs.rb'

# Offense count: 2
Security/Open:
Exclude:
- 'tasks/converter.rb'

# Offense count: 9
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'app/helpers/semantic_breadcrumbs_helper.rb'
- 'app/helpers/semantic_flash_helper.rb'
- 'app/helpers/semantic_icon_helper.rb'
- 'lib/fomantic-ui-sass.rb'
- 'lib/fomantic/ui/sass/breadcrumbs.rb'
- 'lib/fomantic/ui/sass/engine.rb'
- 'tasks/converter.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/fomantic-ui-sass.rb'

# Offense count: 51
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 174
6 changes: 3 additions & 3 deletions Rakefile
@@ -1,8 +1,8 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

desc 'Convert semantic-ui less to sass'
task :convert, :branch do |t, args|
task :convert, :branch do |_t, args|
require './tasks/converter'
branch = args[:branch]
Converter.new(branch).process
end
end
2 changes: 1 addition & 1 deletion app/helpers/semantic_breadcrumbs_helper.rb
@@ -1,6 +1,6 @@
module SemanticBreadcrumbsHelper
def semantic_breadcrumbs(divider = '/', &block)
content = render :partial => 'semantic/breadcrumbs', :layout => false, :locals => { :divider => divider }
content = render partial: 'semantic/breadcrumbs', layout: false, locals: { divider: divider }
if block_given?
capture(content, &block)
else
Expand Down
6 changes: 4 additions & 2 deletions app/helpers/semantic_flash_helper.rb
@@ -1,13 +1,15 @@
module SemanticFlashHelper
ALERT_TYPES = [:error, :info, :success, :warning]
ALERT_TYPES = %i[error info success warning].freeze

def semantic_flash
output = ''
flash.each do |type, message|
next if message.blank?

type = :success if type.to_sym == :notice
type = :error if type.to_sym == :alert
next unless ALERT_TYPES.include?(type.to_sym)

output += flash_container(type, message)
end

Expand All @@ -16,7 +18,7 @@ def semantic_flash

def flash_container(type, message)
content_tag(:div, class: "ui #{type} message") do
content_tag(:i, '', class: "close icon") + message
content_tag(:i, '', class: 'close icon') + message
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/semantic_icon_helper.rb
@@ -1,7 +1,7 @@
module SemanticIconHelper
def semantic_icon(*names)
opts = names[-1].is_a?(Hash) ? names.delete_at(-1) : {}
icon_classes = names.map{|name| "#{name.to_s.gsub('_','-')}" } << 'icon'
icon_classes = names.map { |name| name.to_s.tr('_', '-').to_s } << 'icon'
opts[:class] = [opts[:class], icon_classes].flatten.reject(&:nil?)
content_tag :i, nil, opts
end
Expand Down
28 changes: 14 additions & 14 deletions fomantic-ui-sass.gemspec
@@ -1,32 +1,32 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fomantic/ui/sass/version'

Gem::Specification.new do |spec|
spec.name = "fomantic-ui-sass"
spec.name = 'fomantic-ui-sass'
spec.version = Fomantic::Ui::Sass::VERSION
spec.authors = ["doabit", "shanecav84"]
spec.email = ["doinsist@gmail.com", "shane@shanecav.net"]
spec.description = %q{Fomantic UI, converted to Sass and ready to drop into Rails, Compass, or Sprockets.}
spec.summary = %q{Fomantic UI, converted to Sass and ready to drop into Rails, Compass, or Sprockets.}
spec.homepage = "http://github.com/shanecav84/fomantic-ui-sass"
spec.license = "MIT"
spec.authors = %w[doabit shanecav84]
spec.email = ['doinsist@gmail.com', 'shane@shanecav.net']
spec.description = 'Fomantic UI, converted to Sass and ready to drop into Rails, Compass, or Sprockets.'
spec.summary = 'Fomantic UI, converted to Sass and ready to drop into Rails, Compass, or Sprockets.'
spec.homepage = 'http://github.com/shanecav84/fomantic-ui-sass'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_runtime_dependency 'autoprefixer-rails'
spec.add_runtime_dependency 'rails', '>= 3.2.0'
spec.add_runtime_dependency 'sass', '>= 3.2'
spec.add_runtime_dependency 'sass-rails', '>= 3.2'
spec.add_runtime_dependency 'sprockets-rails', '>= 2.1.3'

spec.add_development_dependency "bundler", ">= 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency 'pry'
spec.add_development_dependency 'bundler', '>= 1.3'
spec.add_development_dependency 'dotenv'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec-rails', '>= 3.0'
spec.add_development_dependency 'rubocop'
end
2 changes: 1 addition & 1 deletion gemfiles/rails_5.0.gemfile
Expand Up @@ -3,6 +3,6 @@ source 'https://rubygems.org'
gem 'rails', '~> 5.0.0'

group :development, :test do
gem 'sass', '>= 3.2'
gem 'rspec-rails', '>= 3.0'
gem 'sass', '>= 3.2'
end
2 changes: 1 addition & 1 deletion gemfiles/rails_5.1.gemfile
Expand Up @@ -3,6 +3,6 @@ source 'https://rubygems.org'
gem 'rails', '~> 5.1.0'

group :development, :test do
gem 'sass', '>= 3.2'
gem 'rspec-rails', '>= 3.0'
gem 'sass', '>= 3.2'
end
2 changes: 1 addition & 1 deletion gemfiles/rails_5.2.gemfile
Expand Up @@ -3,6 +3,6 @@ source 'https://rubygems.org'
gem 'rails', '~> 5.2.0'

group :development, :test do
gem 'sass', '>= 3.2'
gem 'rspec-rails', '>= 3.0'
gem 'sass', '>= 3.2'
end
7 changes: 3 additions & 4 deletions lib/fomantic-ui-sass.rb
Expand Up @@ -7,7 +7,7 @@ def load!
if defined?(::Rails)
require 'fomantic/ui/sass/engine'
elsif defined?(::Compass)
::Compass::Frameworks.register('fomantic-ui', :path => base, :stylesheets_directory => stylesheets_path, :templates_directory => templates_path)
::Compass::Frameworks.register('fomantic-ui', path: base, stylesheets_directory: stylesheets_path, templates_directory: templates_path)
elsif defined?(::Sprockets)
Sprockets.append_path(stylesheets_path)
Sprockets.append_path(fonts_path)
Expand All @@ -16,8 +16,8 @@ def load!
end

configure_sass
if !(defined?(::Rails) || defined?(::Compass) || defined?(::Sprockets))
raise Fomantic::Ui::Sass::FrameworkNotFound, "fomantic-ui-sass requires either Rails > 3.1 or Compass, or Sprockets, none of which are loaded"
unless defined?(::Rails) || defined?(::Compass) || defined?(::Sprockets)
raise Fomantic::Ui::Sass::FrameworkNotFound, 'fomantic-ui-sass requires either Rails > 3.1 or Compass, or Sprockets, none of which are loaded'
end
end

Expand Down Expand Up @@ -54,7 +54,6 @@ def configure_sass
require 'sass'
::Sass.load_paths << stylesheets_path
end

end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/fomantic/ui/sass/breadcrumbs.rb
@@ -1,7 +1,6 @@
module Fomantic
module Ui
module Sass

module BreadCrumbs
def self.included(base)
base.extend(ClassMethods)
Expand All @@ -23,7 +22,7 @@ def semantic_breadcrumb(name, url = '', options = {})
@breadcrumbs ||= []
name = translate_semantic_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
url = eval(url.to_s) if url =~ /_path|_url|@/
@breadcrumbs << {:name => name, :url => url, :options => options}
@breadcrumbs << { name: name, url: url, options: options }
end

def translate_semantic_breadcrumb(name, class_name)
Expand All @@ -32,10 +31,9 @@ def translate_semantic_breadcrumb(name, class_name)
namespace.last.sub!('_controller', '')
scope += namespace

I18n.t name, :scope => scope
I18n.t name, scope: scope
end
end

end
end
end
6 changes: 3 additions & 3 deletions lib/fomantic/ui/sass/engine.rb
Expand Up @@ -4,11 +4,11 @@ module Ui
module Sass
module Rails
class Engine < ::Rails::Engine
initializer "fomantic-ui-sass.assets.precompile" do |app|
initializer 'fomantic-ui-sass.assets.precompile' do |app|
if ::Rails.version >= '5' || ::Sprockets::VERSION.start_with?('4')
::Rails.application.config.assets.precompile += %w{ semantic-ui/*icons.* }
::Rails.application.config.assets.precompile += %w[semantic-ui/*icons.*]
else
app.config.assets.precompile << %r(semantic-ui\/(basic\.)*icons\.(?:eot|svg|ttf|woff)$)
app.config.assets.precompile << %r{semantic-ui\/(basic\.)*icons\.(?:eot|svg|ttf|woff)$}
end
end
initializer 'fomantic-ui-sass.setup_helpers' do |app|
Expand Down
4 changes: 2 additions & 2 deletions lib/fomantic/ui/sass/version.rb
@@ -1,8 +1,8 @@
module Fomantic
module Ui
module Sass
VERSION = "2.6.4"
SEMANTIC_UI_SHA = 'e69d8dff1c3db460bb232b9539a0d1d6cf7ff7cc'
VERSION = '2.6.4'.freeze
SEMANTIC_UI_SHA = 'e69d8dff1c3db460bb232b9539a0d1d6cf7ff7cc'.freeze
end
end
end
2 changes: 1 addition & 1 deletion spec/dummy/Rakefile
@@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

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

Dummy::Application.load_tasks
2 changes: 1 addition & 1 deletion spec/dummy/bin/bundle 100644 → 100755
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
2 changes: 1 addition & 1 deletion spec/dummy/bin/rails 100644 → 100755
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
Empty file modified spec/dummy/bin/rake 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion spec/dummy/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
11 changes: 5 additions & 6 deletions spec/dummy/config/application.rb
@@ -1,14 +1,14 @@
require File.expand_path('../boot', __FILE__)
require File.expand_path('boot', __dir__)

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'sprockets/railtie'
# require "rails/test_unit/railtie"

Bundler.require(*Rails.groups)
require "fomantic-ui-sass"
require 'fomantic-ui-sass'

module Dummy
class Application < Rails::Application
Expand All @@ -25,4 +25,3 @@ class Application < Rails::Application
# config.i18n.default_locale = :de
end
end

6 changes: 3 additions & 3 deletions spec/dummy/config/boot.rb
@@ -1,5 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
2 changes: 1 addition & 1 deletion spec/dummy/config/environment.rb
@@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require File.expand_path('application', __dir__)

# Initialize the Rails application.
Dummy::Application.initialize!
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/test.rb
Expand Up @@ -13,7 +13,7 @@
config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.serve_static_assets = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }

# Show full error reports and disable caching.
Expand Down

0 comments on commit 4ba0ace

Please sign in to comment.