Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Fix tag bug #2033

wants to merge 1 commit into from

Conversation

gemfarmer
Copy link
Contributor

Fixes issue(s) #1947

CircleCI

😎 PREVIEW

Changes proposed in this pull request:

  • references changes made on 18F/jekyll-archives
  • replaces all dashes in archive tags

/cc @coreycaitlin @awfrancisco

}
}
}

.post-list-no-padding {
li:first-child {

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

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))

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

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']

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)

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'>&ldquo;#{post.data['title']}&rdquo;</a></#{internal}>" }
related_posts << "</#{external}"
else
related_posts = "<p>No related posts</p>"

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'>&ldquo;#{post.data['title']}&rdquo;</a></#{internal}>" }

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"

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"

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

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 }}

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)

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

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] )

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer each over for.

@gemfarmer
Copy link
Contributor Author

Closed in favor of #2031

@gemfarmer gemfarmer closed this Nov 9, 2016
@gemfarmer gemfarmer reopened this Nov 9, 2016
@gemfarmer gemfarmer changed the base branch from master to dev November 9, 2016 17:57
@gemfarmer gemfarmer mentioned this pull request Nov 9, 2016
@gemfarmer gemfarmer closed this Nov 9, 2016
@gemfarmer gemfarmer deleted the tag-bug-2 branch November 9, 2016 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants