-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tag bug #2033
Fix tag bug #2033
Conversation
} | ||
} | ||
} | ||
|
||
.post-list-no-padding { | ||
li:first-child { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selector should have depth of applicability no greater than 2, but was 3
end | ||
related_posts = list_posts(other_posts.uniq.take(3)) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at class body end.
if other_posts.flatten.length < 3 | ||
other_posts = get_posts_by_author(other_posts, page, site) | ||
end | ||
related_posts = list_posts(other_posts.uniq.take(3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless assignment to variable - related_posts.
site = context['site'] | ||
siteTags = site['tags'] | ||
other_posts = get_posts_by_tag(page, siteTags) | ||
if other_posts.flatten.length < 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
|
||
page = context['page'] | ||
site = context['site'] | ||
siteTags = site['tags'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use snake_case for variable names.
# grabs more posts by author. Returns a list of the first five posts in the | ||
# array. | ||
def render(context) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at method body beginning.
other_posts.flatten.map { |post| related_posts << "<#{internal}><a href='#{@baseurl}#{post.url}' class='related_posts'>“#{post.data['title']}”</a></#{internal}>" } | ||
related_posts << "</#{external}" | ||
else | ||
related_posts = "<p>No related posts</p>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
internal = @params[1] || "li" | ||
if other_posts | ||
related_posts = "<#{external}>" | ||
other_posts.flatten.map { |post| related_posts << "<#{internal}><a href='#{@baseurl}#{post.url}' class='related_posts'>“#{post.data['title']}”</a></#{internal}>" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [183/100]
# Creates a list of posts from an array of post objects. | ||
def list_posts(other_posts) | ||
external = @params[0] || "ul" | ||
internal = @params[1] || "li" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
|
||
# Creates a list of posts from an array of post objects. | ||
def list_posts(other_posts) | ||
external = @params[0] || "ul" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
authors.map { |author| posts.map { |post| if post.data['authors'] && post.data['authors'].index(author) then other_posts.push(post) end }} | ||
end | ||
other_posts.delete_if { |post| page['title'] == post['title'] } | ||
return other_posts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant return detected.
posts = site['posts'] | ||
if page['authors'] | ||
authors = page['authors'] | ||
authors.map { |author| posts.map { |post| if post.data['authors'] && post.data['authors'].index(author) then other_posts.push(post) end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [146/100]
Space missing inside }.
# Grabs all posts from the site and matches the authors on the current page | ||
# to other posts authored on the site. This may take a long time for large | ||
# sites. Returns an array of posts | ||
def get_posts_by_author(other_posts, page, site) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for get_posts_by_author is too high. [15.43/15]
other_posts = other_posts.flatten.uniq | ||
other_posts.delete_if { |post| page['title'] == post['title'] } | ||
end | ||
return other_posts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant return detected.
tags = page['tags'] | ||
other_posts = [] | ||
for tag in tags | ||
other_posts.push( siteTags[tag] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space inside parentheses detected.
def get_posts_by_tag(page, siteTags) | ||
tags = page['tags'] | ||
other_posts = [] | ||
for tag in tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer each over for.
Closed in favor of #2031 |
Fixes issue(s) #1947
😎 PREVIEW
Changes proposed in this pull request:
/cc @coreycaitlin @awfrancisco