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

PubHash fixes #397

Merged
merged 9 commits into from
Nov 16, 2017
Merged

PubHash fixes #397

merged 9 commits into from
Nov 16, 2017

Conversation

dazza-codes
Copy link
Contributor

@dazza-codes dazza-codes commented Nov 7, 2017

Fix #37
Fix #209
Fix #398

The first commit is a git mv in 82d99ea but github files-changed view is not showing a detailed diff on the PubHash class, it's just showing the entire file moved. This PR will be clearer to review commit-by-commit.

The code-climate issues are not from this PR, but I don't want to mark them "wont-fix". The complexity noted in code-climate existed before this PR. It's picking it up because it seems to see the lib/pub_hash.rb as a new file and everything that was an issue in the old file is somehow fixed. It's not the purpose of this PR to fix all that complexity, although it has helped a bit by extracting parse_author_names.

The code-climate issues are old tech-debt that can be addressed in backlog issues #402, #403, and #404.

@dazza-codes dazza-codes force-pushed the pubhash-to-lib branch 3 times, most recently from 620859c to a4b2cd3 Compare November 7, 2017 06:32
@dazza-codes dazza-codes changed the title [WIP] PubHash fixes PubHash fixes Nov 7, 2017
@dazza-codes dazza-codes force-pushed the pubhash-to-lib branch 3 times, most recently from 0012162 to b1cc320 Compare November 7, 2017 18:15
@peetucket peetucket self-requested a review November 8, 2017 18:58
Copy link
Member

@peetucket peetucket left a comment

Choose a reason for hiding this comment

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

curious as to why the use of casecmp

lib/pub_hash.rb Outdated
def cap_authors_to_csl(cap_authors)
# All the CAP authors are an author if they have no role or they have an 'author' role
authors = cap_authors.map(&:symbolize_keys)
authors.select! { |author| author[:role].nil? || author[:role].to_s.casecmp('author').zero? }
Copy link
Member

Choose a reason for hiding this comment

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

what is the reason for using casecmp here and not something like author[:role].to_s.downcase.include?('author') if we aren't sure of the exact value/case but want to check for the "author" value?

Copy link
Member

Choose a reason for hiding this comment

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

same comment applies to other uses of casecmp in this class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a rubocop thing, apparently casecmp is more efficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed and concluded today that we should disable the rubocop casecmp cop and revise this PR to avoid using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR #420 will disable the rubocop casecmp cop.

lib/pub_hash.rb Outdated
@@ -109,65 +109,65 @@ def csl_doc
}

# Access to abstracts may be restricted by license agreements with data providers.
# cit_data_hash["abstract"] = pub_hash[:abstract] unless pub_hash[:abstract].blank?
Copy link
Member

Choose a reason for hiding this comment

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

presume all the changes in this commit a15f1f1 are rubocop fixes?

@dazza-codes
Copy link
Contributor Author

dazza-codes commented Nov 13, 2017

Replaced use of casecmp with downcase equality matching.

@dazza-codes dazza-codes force-pushed the pubhash-to-lib branch 2 times, most recently from 3a37062 to e29dc92 Compare November 14, 2017 18:15
@peetucket peetucket merged commit 5d3796f into master Nov 16, 2017
@dazza-codes dazza-codes deleted the pubhash-to-lib branch December 5, 2017 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants