hovancik/BSDSec

View on GitHub
app/models/article.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
84%
Article has no descriptive comment
Missing top-level documentation comment for `class Article`.
Missing frozen string literal comment.
class Article < ApplicationRecord
Extra empty line detected at class body beginning.
 
Use 2 (not 4) spaces for indentation.
extend FriendlyId
Use 2 (not 4) spaces for indentation.
friendly_id :title, use: :slugged
 
Use 2 (not 4) spaces for indentation.
has_many :taggings, dependent: :destroy
Use 2 (not 4) spaces for indentation.
has_many :tags, through: :taggings
 
Use 2 (not 4) spaces for indentation.
paginates_per 10
 
Use 2 (not 4) spaces for indentation.
def tag_list
Redundant `self` detected.
Pass `&:name` as an argument to `collect` instead of a block.
self.tags.collect do |tag|
tag.name
Prefer single-quoted strings when you don't need string interpolation or special symbols.
end.join(", ")
end
 
Use 2 (not 4) spaces for indentation.
def tag_list=(tags_string)
Article#tag_list= has the variable name 's'
Space between { and | missing.
Space missing to the left of {.
Space missing inside }.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
tag_names = tags_string.split(",").collect{|s| s.strip.downcase}.uniq
Omit the hash value.
new_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }
self.tags = new_or_found_tags
end
Extra empty line detected at class body end.
 
end