Skip to content

Commit

Permalink
add missing rubocop rules, make suggested corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-sul committed Aug 17, 2024
1 parent 7541ca3 commit aa14d35
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,10 @@ Gemspec/AddRuntimeDependency: # new in 1.65
Enabled: true
Style/SendWithLiteralMethodName: # new in 1.64
Enabled: true

Style/MapIntoArray: # new in 1.63
Enabled: true
Style/SuperArguments: # new in 1.64
Enabled: true
Rails/WhereRange: # new in 2.25
Enabled: true
4 changes: 2 additions & 2 deletions lib/cap/authors_poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def log_stats
info << "#{@too_many_contribs} contributions had more than one instance for an author"
info << "#{@new_auth_with_contribs} new authors had contributions which were ignored"
info << "#{@contribs_changed} contributions were updated"
info << "~#{Publication.where('created_at >= ?', @start_time).count} publications were created."
info << "~#{Contribution.where('created_at >= ?', @start_time).count} contributions were created."
info << "~#{Publication.where(created_at: @start_time..).count} publications were created."
info << "~#{Contribution.where(created_at: @start_time..).count} contributions were created."
logger.info info.join("\n")
end

Expand Down
10 changes: 4 additions & 6 deletions lib/pubmed/map_pub_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,11 @@ def extract_abstract_from_pubmed_record
def extract_mesh_headings_from_pubmed_record
mesh_headings_for_record = []
pubmed_article.xpath('MedlineCitation/MeshHeadingList/MeshHeading').each do |mesh_heading|
descriptors = []
qualifiers = []
mesh_heading.xpath('DescriptorName').each do |descriptor_name|
descriptors << { major: descriptor_name.attr('MajorTopicYN'), name: descriptor_name.text }
descriptors = mesh_heading.xpath('DescriptorName').map do |descriptor_name|
{ major: descriptor_name.attr('MajorTopicYN'), name: descriptor_name.text }
end
mesh_heading.xpath('QualifierName').each do |qualifier_name|
qualifiers << { major: qualifier_name.attr('MajorTopicYN'), name: qualifier_name.text }
qualifiers = mesh_heading.xpath('QualifierName').map do |qualifier_name|
{ major: qualifier_name.attr('MajorTopicYN'), name: qualifier_name.text }
end
mesh_headings_for_record << { descriptor: descriptors, qualifier: qualifiers }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/smci_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def run
contributions = Contribution.select('*')
contributions = contributions.where(author:)
contributions = contributions.where('created_at > ?', Time.zone.parse(@date_since)) if @date_since
contributions = contributions.where('created_at < ?', Time.zone.parse(@date_to)) if @date_to
contributions = contributions.where(created_at: ...Time.zone.parse(@date_to)) if @date_to
num_pubs_found = contributions.size
logger.info "found #{author.first_name} #{author.last_name} with #{num_pubs_found} publications"
total_pubs += num_pubs_found
Expand Down
2 changes: 1 addition & 1 deletion lib/web_of_science/map_abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pub_hash
# Extract content from record, try not to hang onto the entire record
# @param rec [WebOfScience::Record]
def extract(rec)
super(rec)
super
@abstracts = rec.doc.xpath(path).map(&:text)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/web_of_science/map_mesh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def pub_hash
# Extract content from record, try not to hang onto the entire record
# @param rec [WebOfScience::Record]
def extract(rec)
super(rec)
super
@mesh = extract_mesh(rec)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/web_of_science/map_names.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def pub_hash
# Extract content from record, try not to hang onto the entire record
# @param rec [WebOfScience::Record]
def extract(rec)
super(rec)
super
@names = extract_names(rec)
@author_count = names.count { |name| name[:role] == 'author' }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/web_of_science/map_publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def pub_hash
# Extract content from record, try not to hang onto the entire record
# @param rec [WebOfScience::Record]
def extract(rec)
super(rec)
super
@publishers = extract_publishers(rec)
@medline_country = extract_medline_country(rec)
@pub = pub_hash_publisher
Expand Down
2 changes: 1 addition & 1 deletion script/batch_wos_harvest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
authors.each_with_index do |author, i|
puts "Harvesting cap_profile_id #{author.cap_profile_id} [#{i + 1} of #{total}]"
harvester.process_author(author, options)
new_pub_count = author.contributions.where(status: 'new').where('created_at >= ?', start_time).count
new_pub_count = author.contributions.where(status: 'new').where(created_at: start_time..).count
csv << [author.cap_profile_id, "#{author.first_name} #{author.last_name}", new_pub_count]
end
end
Expand Down

0 comments on commit aa14d35

Please sign in to comment.