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 archive tag bug #2031

Closed
wants to merge 10 commits into from
Closed

Fix archive tag bug #2031

wants to merge 10 commits 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


Jekyll::Hooks.register :posts, :pre_render do |post|
tags = post.data['tags'] || []
if tags.any?

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 &&/||.


end


Choose a reason for hiding this comment

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

Extra blank line detected.

# end
# hash
# 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 block body end.


Jekyll::Hooks.register :site, :pre_render do |site|
tags = {}
consolidated_arr = []

Choose a reason for hiding this comment

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

Useless assignment to variable - consolidated_arr.



Jekyll::Hooks.register :site, :pre_render do |site|
tags = {}

Choose a reason for hiding this comment

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

Useless assignment to variable - tags.

end


Jekyll::Hooks.register :site, :pre_render do |site|

Choose a reason for hiding this comment

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

Unused block argument - site. You can omit the argument if you don't care about it.


end


Choose a reason for hiding this comment

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

Extra blank line detected.


def clean_tag(tag)
tag.gsub(/[^0-9A-Za-z]/, ' ').squeeze

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 end.


def days(month_posts)
hash = Hash.new { |h, key| h[key] = [] }
month_posts.each { |p| hash[p.date.strftime("%d")] << 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.


def months(year_posts)
hash = Hash.new { |h, key| h[key] = [] }
year_posts.each { |p| hash[p.date.strftime("%m")] << 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.

if Jekyll::VERSION >= '3.0.0'
@posts.docs.each { |p| hash[p.date.strftime("%Y")] << p }
else
@posts.each { |p| hash[p.date.strftime("%Y")] << 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.


# In Jekyll 3, Collection#each should be called on the #docs array directly.
if Jekyll::VERSION >= '3.0.0'
@posts.docs.each { |p| hash[p.date.strftime("%Y")] << 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.

end

# Custom `post_attr_hash` method for years
def years

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 years is too high. [17.15/15]


# hash[p.date.strftime("%Y")] << p
end
else

Choose a reason for hiding this comment

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

Redundant else-clause.

tag.gsub(/[^0-9A-Za-z]/, ' ').squeeze
end

def tags

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 tags is too high. [21.47/15]
Method has too many lines. [11/10]

def enabled?(archive)
@config["enabled"] == true || @config["enabled"] == "all" || if @config["enabled"].is_a? Array
@config["enabled"].include? archive
end

Choose a reason for hiding this comment

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

end at 87, 8 is not aligned with if at 85, 69.

@gemfarmer gemfarmer changed the title [WIP] Fix archive tag bug Fix archive tag bug Nov 8, 2016
@gemfarmer gemfarmer changed the title Fix archive tag bug [WIP] Fix archive tag bug Nov 8, 2016
@gemfarmer gemfarmer changed the title [WIP] Fix archive tag bug Fix archive tag bug Nov 9, 2016
@gemfarmer
Copy link
Contributor Author

Passed! LGTM!

@coreycaitlin coreycaitlin changed the base branch from master to dev November 9, 2016 17:37
@gemfarmer
Copy link
Contributor Author

Closing because this is a PR to master 😭

@gemfarmer
Copy link
Contributor Author

Nevermind!!!

@gemfarmer gemfarmer mentioned this pull request Nov 9, 2016
@gemfarmer
Copy link
Contributor Author

Closing in favor of #2033

@gemfarmer gemfarmer closed this Nov 9, 2016
@gboone gboone deleted the tag-bug branch February 15, 2017 20:39
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