Skip to content

Commit

Permalink
Merge pull request #2701 from osulp/feature/RubocopFixMe
Browse files Browse the repository at this point in the history
Removes large portion of exclusions
  • Loading branch information
lamtu1 authored Dec 19, 2024
2 parents b8a4eb7 + 4871596 commit 38787e7
Show file tree
Hide file tree
Showing 144 changed files with 1,079 additions and 2,159 deletions.
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require: rubocop-rspec

inherit_from: .rubocop_fix_me.yml
inherit_from: rubocop_fix_me.yml

AllCops:
TargetRubyVersion: 2.5
Expand All @@ -13,6 +13,7 @@ AllCops:
- "bin/**/*"
- "Gemfile"
- "Rakefile"
- "spec/**/*"
- "lib/tasks/**/*"
- "config/**/*"
- "sa_scripts/**/*"
Expand Down
1,095 changes: 0 additions & 1,095 deletions .rubocop_fix_me.yml

This file was deleted.

80 changes: 0 additions & 80 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ GIT
rdf-vocab
sparql-client

GIT
remote: https://github.com/samvera-labs/hyrax-doi.git
revision: 8fb839af0517096bb05f09925fe1aa77fe32b84a
branch: main
specs:
hyrax-doi (0.2.0)
bolognese (~> 1.8, >= 1.8.6)
flipflop (~> 2.3)
hyrax (>= 2.9, < 4.0)
rails (~> 5.2.4, >= 5.2.4.3)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -144,10 +133,6 @@ GEM
bcp47 (0.3.3)
i18n
bcrypt (3.1.20)
benchmark_methods (0.7)
bibtex-ruby (6.1.0)
latex-decode (~> 0.0)
racc (~> 1.7)
bigdecimal (3.1.8)
bindex (0.8.1)
blacklight (6.25.0)
Expand Down Expand Up @@ -180,30 +165,6 @@ GEM
jquery-rails
rails (>= 3.0)
tether-rails
bolognese (1.11.5)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
builder (~> 3.2, >= 3.2.2)
citeproc-ruby (~> 1.1, >= 1.1.12)
colorize (~> 0.8.1)
concurrent-ruby (~> 1.1, >= 1.1.5)
csl-styles (~> 1.0, >= 1.0.1.10)
edtf (~> 3.0, >= 3.0.4)
gender_detector (~> 0.1.2)
iso8601 (~> 0.9.1)
json-ld-preloaded (~> 3.1, >= 3.1.3)
jsonlint (~> 0.3.0)
loofah (~> 2.0, >= 2.0.3)
maremma (>= 4.9.4, < 5)
namae (~> 1.0)
nokogiri (>= 1.13.2, < 1.14)
oj (~> 3.10)
oj_mimic_json (~> 1.0, >= 1.0.1)
postrank-uri (~> 1.0, >= 1.0.18)
rdf-rdfxml (~> 3.1)
rdf-turtle (~> 3.1)
thor (>= 0.19)
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
Expand Down Expand Up @@ -242,11 +203,6 @@ GEM
coffee-rails (>= 3.2)
railties (>= 3.0)
sassc-rails (>= 2.1.2)
citeproc (1.0.10)
namae (~> 1.0)
citeproc-ruby (1.1.14)
citeproc (~> 1.0, >= 1.0.9)
csl (~> 1.6)
clipboard-rails (1.7.1)
cliver (0.3.2)
coderay (1.1.3)
Expand All @@ -257,7 +213,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
colorize (0.8.1)
concurrent-ruby (1.3.1)
connection_pool (2.4.1)
coveralls (0.8.23)
Expand All @@ -270,11 +225,6 @@ GEM
bigdecimal
rexml
crass (1.0.6)
csl (1.6.0)
namae (~> 1.0)
rexml
csl-styles (1.0.1.11)
csl (~> 1.0)
csv (3.3.0)
dalli (3.2.8)
database_cleaner (1.8.5)
Expand Down Expand Up @@ -407,8 +357,6 @@ GEM
jquery-rails
font-awesome-rails (4.7.0.8)
railties (>= 3.2, < 8.0)
gender_detector (0.1.2)
unicode_utils (>= 1.3.0)
geocoder (1.8.3)
base64 (>= 0.1.0)
csv (>= 3.0.0)
Expand Down Expand Up @@ -566,7 +514,6 @@ GEM
activesupport (>= 4)
invisible_captcha (2.3.0)
rails (>= 5.2)
iso8601 (0.9.1)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -596,9 +543,6 @@ GEM
rdf (~> 3.1)
json-schema (4.3.0)
addressable (>= 2.8)
jsonlint (0.3.0)
oj (~> 3)
optimist (~> 3)
jwt (2.8.1)
base64
kaminari (1.2.2)
Expand All @@ -616,7 +560,6 @@ GEM
kaminari_route_prefix (0.1.1)
kaminari (~> 1.0)
language_server-protocol (3.17.0.3)
latex-decode (0.4.0)
ld-patch (3.2.2)
ebnf (~> 2.3)
rdf (~> 3.2)
Expand Down Expand Up @@ -691,17 +634,6 @@ GEM
carrierwave (>= 0.5.8)
rails (>= 5.0.0)
marcel (1.0.4)
maremma (4.9.8)
activesupport (>= 4.2.5)
addressable (>= 2.3.6)
builder (~> 3.2, >= 3.2.2)
excon (~> 0.71.0)
faraday (~> 0.17.3)
faraday-encoding (~> 0.0.4)
faraday_middleware (~> 0.14.0)
nokogiri (>= 1.11.2, < 1.14.0)
oj (>= 2.8.3)
oj_mimic_json (~> 1.0, >= 1.0.1)
matrix (0.4.2)
method_source (1.1.0)
mime-types (3.5.2)
Expand All @@ -715,8 +647,6 @@ GEM
multi_xml (0.6.0)
multipart-post (2.4.1)
mysql2 (0.5.6)
namae (1.2.0)
racc (~> 1.7)
nest (3.2.0)
redic
net-http-persistent (4.0.2)
Expand Down Expand Up @@ -759,13 +689,9 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 4)
oj (3.16.3)
bigdecimal (>= 3.0)
oj_mimic_json (1.0.1)
okcomputer (1.18.5)
openseadragon (0.6.0)
rails (> 3.2.0)
optimist (3.1.0)
orm_adapter (0.5.0)
os (1.1.4)
parallel (1.24.0)
Expand All @@ -778,10 +704,6 @@ GEM
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
posix-spawn (0.3.15)
postrank-uri (1.1)
addressable (>= 2.4.0)
nokogiri (>= 1.8.0)
public_suffix (>= 4.0.0, < 5)
power_converter (0.1.2)
prometheus-client (4.2.2)
pry (0.14.2)
Expand Down Expand Up @@ -1135,7 +1057,6 @@ GEM
execjs (>= 0.3.0, < 3)
unicode-display_width (2.5.0)
unicode-types (1.9.0)
unicode_utils (1.4.0)
validatable (1.6.7)
valkyrie (2.2.0)
activemodel
Expand Down Expand Up @@ -1227,7 +1148,6 @@ DEPENDENCIES
honeycomb-beeline (>= 2.10.0)
hydra-role-management
hyrax (= 3.6.0)
hyrax-doi!
invisible_captcha
jbuilder (~> 2.5)
jquery-rails
Expand Down
20 changes: 10 additions & 10 deletions app/actors/scholars_archive/actors/add_other_field_option_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def degree_present?(env)

def save_custom_option(env)
puts 'save custom option if any'
if degree_present? (env)
if degree_present?(env)
if env.attributes['degree_field_other'].present? && is_valid_other_field_multiple?(env, :degree_field)
puts 'saving degree field other and notifying admin'
all_new_entries = persist_multiple_other_entries(env, :degree_field)
Expand All @@ -51,7 +51,7 @@ def save_custom_option(env)
notify_admin(env, field: :degree_grantors, new_entries: env.curation_concern.degree_grantors_other)
end

if other_affiliation_other_present? (env)
if other_affiliation_other_present?(env)
puts 'other affiliation other and notifying admin'
all_new_entries = persist_multiple_other_entries(env, :other_affiliation)
notify_admin(env, field: :other_affiliation, new_entries: all_new_entries)
Expand Down Expand Up @@ -105,7 +105,7 @@ def persist_multiple_other_entries(env, field)
puts 'persist multiple other entries'
all_current_entries = get_all_other_options(env, field).map(&:name)
all_new_entries = []
other_field = "#{field.to_s}_other"
other_field = "#{field}_other"

return all_new_entries if env.attributes[other_field].blank?

Expand All @@ -120,7 +120,7 @@ def persist_multiple_other_entries(env, field)
end

def update_custom_option(env)
if degree_present? (env)
if degree_present?(env)
if is_valid_other_field_multiple?(env, :degree_field)

all_new_entries = persist_multiple_other_entries(env, :degree_field)
Expand Down Expand Up @@ -154,7 +154,7 @@ def update_custom_option(env)
end
end

if other_affiliation_other_present? (env)
if other_affiliation_other_present?(env)
all_new_entries = persist_multiple_other_entries(env, :other_affiliation)
notify_admin(env, field: :other_affiliation, new_entries: all_new_entries)
end
Expand All @@ -168,11 +168,11 @@ def degree_grantors_present?(record)
end

def notify_admin(env, field:, new_entries:)
if new_entries.present? && new_entries.respond_to?(:size) && new_entries.size > 0
ScholarsArchive::OtherOptionCreateSuccessService.new(env.curation_concern,
field: field,
new_entries: new_entries).call
end
return unless new_entries.present? && new_entries.respond_to?(:size) && new_entries.size.positive?

ScholarsArchive::OtherOptionCreateSuccessService.new(env.curation_concern,
field: field,
new_entries: new_entries).call
end

def get_other_option(env, field)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,47 @@ def nested_geo_present?(env)
end

def set_geo_coordinates(env)
if env.attributes['nested_geo_attributes']
env.attributes['nested_geo_attributes'].each do |box, value|
if [value['label'], value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']].none? { |f| !f.present? }
bbox = [value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']]
value['bbox'] = bbox.join(',')
end
if [value['label'], value['point_lat'], value['point_lon']].none? { |f| !f.present? }
point = [value['point_lat'], value['point_lon']]
value['point'] = point.join(',')
end
return unless env.attributes['nested_geo_attributes']

env.attributes['nested_geo_attributes'].each do |_box, value|
if [value['label'], value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']].none? { |f| !f.present? }
bbox = [value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']]
value['bbox'] = bbox.join(',')
end
if [value['label'], value['point_lat'], value['point_lon']].none? { |f| !f.present? }
point = [value['point_lat'], value['point_lon']]
value['point'] = point.join(',')
end
clean_up_nested_attributes(env)
end
clean_up_nested_attributes(env)
end

def save_nested_elements(env)
clean_up_fields(env)
return true unless nested_geo_present? (env)
return true unless nested_geo_present?(env)

set_geo_coordinates(env)
true
end

def update_nested_elements(env)
clean_up_fields(env)
return true unless nested_geo_present? (env)
return true unless nested_geo_present?(env)

set_geo_coordinates(env)
true
end

def clean_up_fields(env)
# Note: since we aren't storing "Other" values in fedora for other_affiliation, here we can skip them
# NOTE: since we aren't storing "Other" values in fedora for other_affiliation, here we can skip them
# for the model and only keep valid uri values. add_other_field_option_actor is responsible for persisting the
# text values provided by the user for these "Other" entries. Here we are just removing/cleaning up the
# selection before getting to the ModelActor, which is where the attributes appears to be persisted in fedora
env.attributes['other_affiliation'].to_a.delete_if { |x| x == 'Other' } if env.attributes['other_affiliation']
env.attributes['other_affiliation']&.to_a&.delete_if { |x| x == 'Other' }
end

def clean_up_nested_attributes(env)
env.attributes['nested_geo_attributes'].each do |k, v|
env.attributes['nested_geo_attributes'].each do |_k, v|
v.delete('point_lon')
v.delete('point_lat')
v.delete('bbox_lat_north')
Expand Down
8 changes: 3 additions & 5 deletions app/authorities/parsers/academic_units_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ def self.parse(jsonld)
extract_and_massage_data(jsonld)
end

private

def self.extract_and_massage_data(jsonld)
graph = JSON.parse(jsonld).dig('@graph')
graph = JSON.parse(jsonld)['@graph']
return [{ id: 'invalid', term: 'invalid', active: true }] if graph.nil?

terms = graph.map { |g| { id: g.dig('@id'), term: labels_with_dates(g), active: true } }
terms = graph.map { |g| { id: g['@id'], term: labels_with_dates(g), active: true } }
# return only terms that have id and label
terms.delete_if { |term| term[:id].nil? || term[:term].nil? }
end
Expand All @@ -22,7 +20,7 @@ def self.labels_with_dates(g)
label = g.dig('rdfs:label', '@value')
return label if label.nil?

date = g.dig('dc:date')
date = g['dc:date']
date = g.dig('dc:date', '@value') if date.is_a?(Hash)
date = date.join(', ') if date.is_a?(Array)
"#{label} - #{date}"
Expand Down
10 changes: 4 additions & 6 deletions app/authorities/parsers/degree_fields_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ def self.parse(jsonld)
extract_and_massage_data(jsonld)
end

private

def self.extract_and_massage_data(jsonld)
graph = JSON.parse(jsonld).dig('@graph')
graph = JSON.parse(jsonld)['@graph']
return [{ id: 'invalid', term: 'invalid', active: true }] if graph.nil?

terms = graph.map { |g| { id: g.dig('@id'), term: labels_with_dates(g), active: true } unless deprecated?(g) }.compact
terms = graph.map { |g| { id: g['@id'], term: labels_with_dates(g), active: true } unless deprecated?(g) }.compact
# return only terms that have id and label
terms.delete_if { |term| term[:id].nil? || term[:term].nil? }
end
Expand All @@ -22,15 +20,15 @@ def self.labels_with_dates(g)
label = g.dig('rdfs:label', '@value')
return label if label.nil?

date = g.dig('dc:date')
date = g['dc:date']
date = g.dig('dc:date', '@value') if date.is_a?(Hash)
date = date.join(', ') if date.is_a?(Array)
"#{label} - #{date}"
end

def self.deprecated?(g)
# return true if value is in isReplacedBy
g.dig('dc:isReplacedBy')
g['dc:isReplacedBy']
end
end
end
Loading

0 comments on commit 38787e7

Please sign in to comment.