Merge pull request #2349 from Br3nda/rails-target

Update rubocop to represent to rails 5.2
This commit is contained in:
Brenda Wallace
2019-12-26 13:53:33 +13:00
committed by GitHub
558 changed files with 1117 additions and 72 deletions

View File

@@ -4,7 +4,7 @@ AllCops:
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
TargetRailsVersion: 5.0
TargetRailsVersion: 5.2
Rails:
Enabled: true
@@ -15,15 +15,6 @@ Naming/FileName:
- 'Gemfile'
- 'Gemfile.lock'
Style/StringLiterals:
Enabled: false
Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: ()
'%i': ()
'%w': ()
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
@@ -36,11 +27,16 @@ Layout/HashAlignment:
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation
Style/Documentation:
Style/StringLiterals:
Enabled: false
Style/FrozenStringLiteralComment:
Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: ()
'%i': ()
'%w': ()
Style/Documentation:
Enabled: false
# Configuration parameters: Include.
@@ -56,22 +52,9 @@ Metrics/BlockLength:
- '**/*.rake'
- 'config/**/*.rb'
Metrics/LineLength:
Layout/LineLength:
Max: 140
# Remove the following once the code style matches
Metrics/MethodLength:
Max: 34
Metrics/AbcSize:
Max: 33
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 171
Metrics/CyclomaticComplexity:
Max: 8
Metrics/PerceivedComplexity:
Max: 9
# Places we use update_all, etc even though it skips validations.
Rails/SkipsModelValidations:
Exclude:

View File

@@ -10,48 +10,6 @@ Lint/AmbiguousOperator:
Exclude:
- 'spec/controllers/crops_controller_spec.rb'
# Configuration parameters: AllowComments.
Lint/SuppressedException:
Exclude:
- 'lib/tasks/testing.rake'
Lint/UselessAssignment:
Exclude:
- 'config.rb'
- 'config/compass.rb'
Metrics/AbcSize:
Max: 125
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 59
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 186
Metrics/CyclomaticComplexity:
Max: 29
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 341
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 106
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 107
Metrics/PerceivedComplexity:
Max: 29
# Configuration parameters: EnforcedStyle.
# SupportedStyles: lowercase, uppercase
Naming/HeredocDelimiterCase:

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class MembersController < ApplicationController
before_action :admin!

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class RolesController < ApplicationController
before_action :admin!

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AdminController < ApplicationController
respond_to :html
def index

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AlternateNamesController < ApplicationController
before_action :authenticate_member!, except: %i(index)
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class BaseController < JSONAPI::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class CropsController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class GardensController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class HarvestsController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class MembersController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class PhotosController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class PlantingsController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class SeedsController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require './lib/actions/oauth_signup_action'
class AuthenticationsController < ApplicationController
before_action :authenticate_member!

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Charts
class CropsController < ApplicationController
respond_to :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Charts
class GardensController < ApplicationController
respond_to :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommentsController < ApplicationController
before_action :authenticate_member!, except: %i(index)
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ConversationsController < ApplicationController
respond_to :html
before_action :authenticate_member!

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'will_paginate/array'
class CropsController < ApplicationController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class FollowsController < ApplicationController
before_action :set_member, only: %i(index followers)
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForumsController < ApplicationController
load_and_authorize_resource
respond_to :html, :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class GardenTypesController < ApplicationController
respond_to :html, :json
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class HomeController < ApplicationController
skip_authorize_resource
respond_to :html

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class LikesController < ApplicationController
before_action :authenticate_member!
respond_to :html, :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MembersController < ApplicationController
load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show)
skip_authorize_resource only: %i(nearby unsubscribe finish_signup)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MessagesController < ApplicationController
respond_to :html, :json
before_action :authenticate_member!

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require './lib/actions/oauth_signup_action'
#

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PagesController < ApplicationController
def letsencrypt
# use your code here, not mine

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PasswordsController < Devise::PasswordsController
protected

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PhotoAssociationsController < ApplicationController
before_action :authenticate_member!
respond_to :json, :html

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PhotosController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
after_action :expire_homepage, only: %i(create destroy)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PlacesController < ApplicationController
skip_authorize_resource
respond_to :html, :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PlantPartsController < ApplicationController
load_and_authorize_resource
respond_to :html, :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostsController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
respond_to :json

View File

@@ -1,5 +1,7 @@
# frozen_string_literal: true
class RobotsController < ApplicationController
DEFAULT_FILENAME = 'config/robots.txt'.freeze
DEFAULT_FILENAME = 'config/robots.txt'
def robots
filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ScientificNamesController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class SessionsController < Devise::SessionsController
respond_to :html, :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class TimelineController < ApplicationController
def index
if current_member

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ApplicationHelper
def parse_date(str)
str ||= '' # Date.parse barfs on nil

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module AutoSuggestHelper
def auto_suggest(resource, source, options = {})
if options[:default] && !options[:default].new_record?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ButtonsHelper
include IconsHelper
def garden_plant_something_button(garden, classes: "btn btn-default")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module CropsHelper
def display_seed_availability(member, crop)
seeds = member.seeds.where(crop: crop)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module EditableFormHelper
def editable(field_type, model, field, display_field:, collection: [])
render 'shared/editable/form', field_type: field_type,

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module EventHelper
def in_weeks(days)
(days / 7.0).round

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module GardensHelper
def display_garden_description(garden)
if garden.description.nil?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module HarvestsHelper
def display_quantity(harvest)
human_quantity = display_human_quantity(harvest)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module IconsHelper
include FontAwesome::Sass::Rails::ViewHelpers

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PhotosHelper
def crop_image_path(crop)
thumbnail_url(crop.default_photo)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PlantingsHelper
def display_finished(planting)
if planting.finished_at.present?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PostsHelper
def display_post_truncated(post)
length = 300

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module SeedsHelper
def display_seed_quantity(seed)
if seed.quantity.nil?

View File

@@ -1,2 +1,4 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Notifier < ApplicationMailer
# include NotificationsHelper
default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Ability
include CanCan::Ability

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AlternateName < ApplicationRecord
belongs_to :crop
belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
self.per_page = 36

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Authentication < ApplicationRecord
belongs_to :member
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Comment < ApplicationRecord
belongs_to :author, class_name: 'Member', inverse_of: :comments
belongs_to :post

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Finishable
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Likeable
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module MemberFlickr
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module MemberNewsletter
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module OpenFarmData
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ownable
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PhotoCapable
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PredictHarvest
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module PredictPlanting
extend ActiveSupport::Concern

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Crop < ApplicationRecord
extend FriendlyId
include PhotoCapable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CropCompanion < ApplicationRecord
belongs_to :crop_a, class_name: :Crop
belongs_to :crop_b, class_name: :Crop

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CropPost < ApplicationRecord
belongs_to :crop
belongs_to :post

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CsvImporter
# used by db/seeds.rb and rake growstuff:import_crops
# CSV fields:

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Follow < ApplicationRecord
belongs_to :follower, class_name: "Member", inverse_of: :follows
belongs_to :followed, class_name: "Member", inverse_of: :inverse_follows

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Forum < ApplicationRecord
extend FriendlyId
include Ownable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Garden < ApplicationRecord
extend FriendlyId
include Geocodable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class GardenType < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Harvest < ApplicationRecord
include ActionView::Helpers::NumberHelper
extend FriendlyId

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Like < ApplicationRecord
belongs_to :member
belongs_to :likeable, polymorphic: true, counter_cache: true

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Member < ApplicationRecord
include Discard::Model
acts_as_messageable # messages can be sent to this model

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Notification < ApplicationRecord
belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications
belongs_to :recipient, class_name: 'Member', inverse_of: :notifications

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Photo < ApplicationRecord
include Likeable
include Ownable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PhotoAssociation < ApplicationRecord
belongs_to :photo, inverse_of: :photo_associations
belongs_to :photographable, polymorphic: true

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PlantPart < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Planting < ApplicationRecord
extend FriendlyId
include PhotoCapable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Post < ApplicationRecord
extend FriendlyId
include Likeable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Role < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i(slugged finders)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ScientificName < ApplicationRecord
belongs_to :crop
belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Seed < ApplicationRecord
extend FriendlyId
include PhotoCapable

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class CropResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class GardenResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class HarvestResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class MemberResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class PhotoResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class PlantingResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class SeedResource < BaseResource

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class BaseResource < JSONAPI::Resource
immutable
abstract

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CropSearchService
# Crop.search(string)
def self.search(query, page: 1, per_page: 12, current_member: nil)

Some files were not shown because too many files have changed in this diff Show More