Byte4/acebook-byte4

View on GitHub
app/controllers/likes_controller.rb

Summary

Maintainability
A
30 mins
Test Coverage

Showing 11 of 11 total issues

Assignment Branch Condition size for create is too high. [17.06/15]
Open

def create
like = Like.where('post_id = ? AND user_id = ?', params[:post_id], current_user.id)
if like.count <= 0
Like.create({'post_id': params[:post_id], 'user_id': current_user.id})
else
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def create
like = Like.where('post_id = ? AND user_id = ?', params[:post_id], current_user.id)
if like.count <= 0
Like.create({'post_id': params[:post_id], 'user_id': current_user.id})
else
Severity: Minor
Found in app/controllers/likes_controller.rb and 1 other location - About 30 mins to fix
app/controllers/dislikes_controller.rb on lines 6..13

Redundant curly braces around a hash parameter.
Open

Like.create({'post_id': params[:post_id], 'user_id': current_user.id})
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Missing top-level class documentation comment.
Open

class LikesController < ApplicationController
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Extra empty line detected at method body end.
Open

 
end
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Space inside { missing.
Open

Like.create({'post_id': params[:post_id], 'user_id': current_user.id})
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Extra empty line detected at class body beginning.
Open

 
# POST /likes
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Space inside } missing.
Open

Like.create({'post_id': params[:post_id], 'user_id': current_user.id})
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Extra empty line detected at class body end.
Open

 
end
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Missing magic comment # frozen_string_literal: true.
Open

class LikesController < ApplicationController
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

Line is too long. [87/80]
Open

like = Like.where('post_id = ? AND user_id = ?', params[:post_id], current_user.id)
Severity: Minor
Found in app/controllers/likes_controller.rb by rubocop

There are no issues that match your filters.

Category
Status