rubocop: Metrics/*, 655

Turned off everything but LineLength, which I bumped to 100 and manually
tidied.
This commit is contained in:
Peter Bhat Harkins 2018-03-14 09:47:35 -06:00
parent 113bb5e9cc
commit a15c5d540e
12 changed files with 51 additions and 26 deletions

View File

@ -35,6 +35,26 @@ Lint/EndAlignment:
EnforcedStyleAlignWith: variable
# Metrics
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/LineLength:
Max: 100
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
# Naming

View File

@ -84,11 +84,13 @@ class ApplicationController < ActionController::Base
color = :red
[
# rubocop:disable Metrics/LineLength,
[2_000_000, :blue, "background-color: #0000#{intensity};"],
[6, :yellow, "background-color: ##{intensity}#{intensity}00;"],
[3, :calico, "background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAC4jAAAuIwF4pT92AAAABmJLR0QA/wD/AP+gvaeTAAACpElEQVQYGQXBWW8bVRgA0Hu/u814NsdxGsUxztJUzaJSVS1CCCTKE7zxxiP/gH+I+lKKQEVCLUlJ5YTsU8f2eJvxbHfjHLz7sKeU2mhNfvl579vnEPKUEUJxji1YoBaIob4m6+cX8Our/m99TBwmpKGV0hZjz+EO06FHOAKlFNKIcE+p8HYo3rwd/Xk8m+pVEjW4EzIFdjopVVG6Nt1ocpc3ALnIhqMRnF3afz6qd2flcMElAOWu3nm4tr6xMh2cyDpprqwBwdjQ0Uz9fXJ9el0lRTOekVQ13DCKvCXVWO7sdl6+/Gp01cbpv/uHPcqGlUKIr50NZq+Pi7mymrt+GOxvbz9+zKjS5OLi1uV/ZeObAC3un4qgt+c0bL8/v5qJ64WbaocIPC2HzbaDGCOeF0ySJI7vzz9eLuZFpfDq2lZWmd/fx6/e3twkuDIiL3KCysV83D+/xZ/1uhYXjuC6lg0BVk2fHPXcQMWD7L+bvJCettzhEPpgzRIxjbe3u6VMCcXWMEY5E9qisqo1QlRLjDVwxqxSQpBW5CFnSB2PaulyRleCSEtNhDPLltjkdQWYCC+gDVF6pHzU8z8/7IKgVFaVtshSWaQxA2Osz4FiokTQrLRrQCLIXzxr/fT94cFWVFlGmXExNQznnbbzaGcVgb0bJqO8kS5BzmusNAMdYN5mPlsihRh5sL7pRYHXQM+OOj/+8MV3Xx+2mmQ8qQZxkmfKSGXq1Odyt9MShByffKLgcc3JsqrHk3Eyumu6LbkYFHcfsjttSaR5OFP29H755nzw/sq8+yMh/sYKYiRL76dxzOqr9RBsmeisnCWqVlZaMIyxgC5U9eEy7p9awj0ByDiQ7XfgmyfRl0fRwZbb7bLVNmOOXynADDY3Hxzs7+WL5XSY/w/0MGrkMYhXjAAAAABJRU5ErkJggg==) no-repeat center"],
[2, :split, "background: linear-gradient(90deg, ##{intensity}0000 50%, #0000#{intensity} 50%)"],
[2, :albino, "filter: invert(100%);"],
# rubocop:enable Metrics/LineLength,
].each do |cumulative_odds, name, style|
break unless rand(cumulative_odds) == 0
color = name

View File

@ -9,7 +9,8 @@ class ReplyingComment < ApplicationRecord
.preload(:comment => [:story, :user])
}
scope :unread_replies_for, ->(user_id) { for_user(user_id).where(is_unread: true) }
scope :comment_replies_for, ->(user_id) { for_user(user_id).where('parent_comment_id is not null') }
scope :comment_replies_for,
->(user_id) { for_user(user_id).where('parent_comment_id is not null') }
scope :story_replies_for, ->(user_id) { for_user(user_id).where('parent_comment_id is null') }
protected

View File

@ -48,6 +48,9 @@ class Story < ActiveRecord::Base
# let a hot story linger for this many seconds
HOTNESS_WINDOW = 60 * 60 * 22
# drop these words from titles when making URLs
TITLE_DROP_WORDS = ["", "a", "an", "and", "but", "in", "of", "or", "that", "the", "to"].freeze
# link shortening and other ad tracking domains
TRACKING_DOMAINS = %w{ 1url.com 7.ly adf.ly al.ly bc.vc bit.do bit.ly
bitly.com buzurl.com cur.lv cutt.us db.tt db.tt doiop.com filoops.info
@ -695,7 +698,11 @@ class Story < ActiveRecord::Base
.parameterize
.gsub(/[^a-z0-9]/, "_")
.split("_")
<<<<<<< HEAD
.reject {|z| ["", "a", "an", "and", "but", "in", "of", "or", "that", "the", "to"] .include?(z) }
=======
.reject { |z| TITLE_DROP_WORDS.include?(z) }
>>>>>>> 777001a... rubocop: Metrics/*, 805
.each do |w|
if wl + w.length <= max_len
words.push w

View File

@ -16,7 +16,7 @@ Lobsters::Application.configure do
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# For large-scale production use, consider using a caching reverse proxy (nginx, varnish, squid)
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
@ -32,7 +32,7 @@ Lobsters::Application.configure do
# Generate digests for assets URLs.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# `config.assets.precompile` and `config.assets.version` moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache

View File

@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# You can add backtrace silencers for libraries that you're using but don't wish to see
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# You can also remove all the silencers to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -122,8 +122,10 @@ Lobsters::Application.routes.draw do
post "/users/:username/ban" => "users#ban", :as => "user_ban"
post "/users/:username/unban" => "users#unban", :as => "user_unban"
post "/users/:username/disable_invitation" => "users#disable_invitation", :as => "user_disable_invite"
post "/users/:username/enable_invitation" => "users#enable_invitation", :as => "user_enable_invite"
post "/users/:username/disable_invitation" => "users#disable_invitation",
:as => "user_disable_invite"
post "/users/:username/enable_invitation" => "users#enable_invitation",
:as => "user_enable_invite"
get "/settings" => "settings#index"
post "/settings" => "settings#update"

View File

@ -189,7 +189,8 @@ class Sponge
}.merge(send_headers || {})
if uri.user
send_headers["Authorization"] = "Basic " + ["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n")
send_headers["Authorization"] = "Basic " +
["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n")
end
res = nil

View File

@ -80,7 +80,8 @@ Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each d
domain = Rails.application.domain
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@#{ails.application.domain}"
IO.popen([{}, "/usr/sbin/sendmail", "-i", "-f", "nobody@#{Rails.application.domain}", u.email], "w") do |mail|
IO.popen([{}, "/usr/sbin/sendmail", "-i", "-f", "nobody@#{Rails.application.domain}", u.email],
"w") do |mail|
mail.puts "From: #{s.user.username} <#{s.user.username}@#{Rails.application.domain}>"
mail.puts "Reply-To: #{list}"
mail.puts "To: #{list}"

View File

@ -1,21 +1,9 @@
#!/usr/bin/env ruby
#
# postfix main.cf:
# relay_domains = example.com
# transport_maps = hash:/etc/postfix/transport
# defer_transports =
#
# postfix transports:
# example.com lobsters:
#
# postfix master.cf:
# lobsters unix - n n - 2 pipe
# flags=Fqhu user=lobsters size=1024000 argv=/d/rails/lobsters/script/parse_inbound_mail ${recipient} ${sender}
ENV["RAILS_ENV"] ||= "production"
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require APP_PATH
Rails.application.require_environment!

View File

@ -57,7 +57,8 @@ describe EmailParser do
expect(parser.email).to_not be_nil
expect(parser.body)
.to eq("It hasn't decreased any measurable amount but since the traffic to\nthe site is increasing a bit each week, it's hard to tell.")
.to eq("It hasn't decreased any measurable amount but since the traffic to\n" <<
"the site is increasing a bit each week, it's hard to tell.")
end
it "strips quoted lines with attribution" do
@ -69,6 +70,7 @@ describe EmailParser do
expect(parser.email).to_not be_nil
expect(parser.body)
.to eq("It hasn't decreased any measurable amount but since the traffic to\nthe site is increasing a bit each week, it's hard to tell.")
.to eq("It hasn't decreased any measurable amount but since the traffic to\n" <<
"the site is increasing a bit each week, it's hard to tell.")
end
end

View File

@ -30,7 +30,8 @@ describe User do
end
it "gets an error message after registering banned name" do
expect { User.make!(:username => "admin") }.to raise_error("Validation failed: Username is not permitted")
expect { User.make!(:username => "admin") }
.to raise_error("Validation failed: Username is not permitted")
end
it "shows a user is banned or not" do