[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io
2019-12-20 04:16:33 +00:00
parent 9234ca0a6d
commit f8916dfecb
8 changed files with 28 additions and 28 deletions

View File

@@ -14,14 +14,14 @@ class AuthenticationsController < ApplicationController
@authentication = current_member.authentications
.create_with(
name: name,
token: auth['credentials']['token'],
name: name,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name: name
uid: auth['uid'],
name: name
)
flash[:notice] = "Authentication successful."

View File

@@ -56,7 +56,7 @@ class ConversationsController < ApplicationController
def set_box
@boxes = {
'inbox' => { 'total' => mailbox.inbox.size, 'unread' => current_member.receipts.where(is_read: false).count },
'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 },
'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 },
'trash' => { 'total' => mailbox.trash.size, 'unread' => 0 }
}
@box = if params[:box].blank? || !@boxes.keys.include?(params[:box])

View File

@@ -52,8 +52,8 @@ class CropsController < ApplicationController
@term = params[:term]
@crops = CropSearchService.search(
@term, page: params[:page],
per_page: 36,
@term, page: params[:page],
per_page: 36,
current_member: current_member
)
respond_with @crops
@@ -204,13 +204,13 @@ class CropsController < ApplicationController
def crop_json_fields
{
include: {
plantings: {
plantings: {
include: {
owner: { only: %i(id login_name location latitude longitude) }
}
},
scientific_names: { only: [:name] },
alternate_names: { only: [:name] }
alternate_names: { only: [:name] }
}
}
end

View File

@@ -30,11 +30,11 @@ class LikesController < ApplicationController
def render_json(like, liked_by_member: true)
{
id: like.likeable.id,
like_count: like.likeable.likes.count,
id: like.likeable.id,
like_count: like.likeable.likes.count,
liked_by_member: liked_by_member,
description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"),
url: like_path(like, format: :json)
description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"),
url: like_path(like, format: :json)
}
end
@@ -42,8 +42,8 @@ class LikesController < ApplicationController
respond_to do |format|
format.html { redirect_to like.likeable }
format.json do
render(json: render_json(like,
liked_by_member: liked_by_member),
render(json: render_json(like,
liked_by_member: liked_by_member),
status: status_code)
end
end

View File

@@ -71,7 +71,7 @@ class MembersController < ApplicationController
EMAIL_TYPE_STRING = {
send_notification_email: "direct message notifications",
send_planting_reminder: "planting reminders"
send_planting_reminder: "planting reminders"
}.freeze
def member_params

View File

@@ -86,7 +86,7 @@ class PhotosController < ApplicationController
def find_or_create_photo_from_flickr_photo
photo = Photo.find_or_initialize_by(
source_id: photo_params[:source_id],
source: 'flickr'
source: 'flickr'
)
photo.update(photo_params)
photo.owner_id = current_member.id

View File

@@ -29,11 +29,11 @@ class PlantingsController < ApplicationController
end
@plantings = Planting.search(
where: @where,
page: params[:page],
limit: 30,
where: @where,
page: params[:page],
limit: 30,
boost_by: [:created_at],
load: false
load: false
)
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"
@@ -59,15 +59,15 @@ class PlantingsController < ApplicationController
def new
@planting = Planting.new(
planted_at: Time.zone.today,
owner: current_member,
garden: current_member.gardens.first
owner: current_member,
garden: current_member.gardens.first
)
@seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id]
@crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new
if params[:garden_id]
@planting.garden = Garden.find_by(
owner: current_member,
id: params[:garden_id]
id: params[:garden_id]
)
end

View File

@@ -32,11 +32,11 @@ class SeedsController < ApplicationController
@filename = csv_filename
@seeds = Seed.search(
where: where,
page: params[:page],
limit: 30,
where: where,
page: params[:page],
limit: 30,
boost_by: [:created_at],
load: false
load: false
)
respond_with(@seeds)