Skip to content

Commit

Permalink
Fixed lint errors for event data (#123)
Browse files Browse the repository at this point in the history
* Fixed lint errors

* Revert "Fixed lint errors"

This reverts commit e7d3c67.

* Fixed lint errors

* Fixed lint errors in recently added files
  • Loading branch information
ashwinisukale authored Nov 21, 2023
1 parent 5863be7 commit a0a12d8
Show file tree
Hide file tree
Showing 25 changed files with 424 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ Rails/Validation:
Description: 'Use validates :attribute, hash of validations.'
Enabled: false

Gemspec/DateAssignment: # (new in 1.10)
Gemspec/DeprecatedAttributeAssignment: # (new in 1.10)
Enabled: true
Layout/SpaceBeforeBrackets: # (new in 1.7)
Enabled: true
Expand Down
91 changes: 46 additions & 45 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gem 'rails', '6.0'
gem 'bootsnap', '~> 1.2', '>= 1.2.1'
gem 'dotenv'
gem "oj", ">= 2.8.3"
gem "oj_mimic_json", "~> 1.0", ">= 1.0.1"
gem 'equivalent-xml', '~> 0.6.0'
gem 'nokogiri', '~> 1.13.2'
gem 'iso8601', '~> 0.9.0'
gem 'maremma', '~> 4.9.6'
source "https://rubygems.org"

gem "active_model_serializers", "~> 0.10.0"
gem "api-pagination"
gem "aws-sdk-sqs", "~> 1.3"
gem "bcrypt", "~> 3.1.7"
gem "bolognese", "~> 1.11.5"
gem "bootsnap", "~> 1.2", ">= 1.2.1"
gem "cancancan", "~> 2.0"
gem "countries", "~> 2.1", ">= 2.1.2"
gem "country_select", "~> 3.1"
gem "dalli", "~> 2.7.6"
gem "dotenv"
gem "equivalent-xml", "~> 0.6.0"
gem "facets", require: false
gem "faraday_middleware-aws-sigv4", "~> 0.2.4"
gem "git", "~> 1.5"
gem "iso8601", "~> 0.9.0"
gem "jwt"
gem "kaminari", "~> 1.0", ">= 1.0.1"
gem "lograge", "~> 0.11.2"
gem "logstash-event", "~> 1.2", ">= 1.2.02"
gem "logstash-logger", "~> 0.26.1"
gem 'sentry-raven', '~> 2.9'
gem 'active_model_serializers', '~> 0.10.0'
gem 'jwt'
gem 'bcrypt', '~> 3.1.7'
gem 'simple_command'
gem 'kaminari', '~> 1.0', '>= 1.0.1'
gem 'api-pagination'
gem 'cancancan', '~> 2.0'
gem 'country_select', '~> 3.1'
gem 'countries', '~> 2.1', '>= 2.1.2'
gem "facets", require: false
gem "bolognese", "~> 1.11.5"
gem "maremma", "~> 4.9.6"
gem "nokogiri", "~> 1.13.2"
gem "oj", ">= 2.8.3"
gem "oj_mimic_json", "~> 1.0", ">= 1.0.1"
gem "rack-cors", "~> 1.0", require: "rack/cors"
gem "rack-utf8_sanitizer", "~> 1.6"
gem "rails", "6.0"
gem "sentry-raven", "~> 2.9"
gem "shoryuken", "~> 4.0"
gem 'rack-cors', '~> 1.0', :require => 'rack/cors'
gem 'rack-utf8_sanitizer', '~> 1.6'
gem 'slack-notifier', '~> 2.3', '>= 2.3.2'
gem 'aws-sdk-sqs', '~> 1.3'
gem 'faraday_middleware-aws-sigv4', '~> 0.2.4'
gem 'git', '~> 1.5'
gem "simple_command"
gem "slack-notifier", "~> 2.3", ">= 2.3.2"
gem "sprockets", "~> 3.7", ">= 3.7.2"

group :development, :test do
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem "better_errors"
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rubocop', '~> 0.77.0'
gem 'rubocop-performance', '~> 1.5', '>= 1.5.1'
gem 'rubocop-rails', '~> 2.4'
gem "byebug", platforms: %i[mri mingw x64_mingw]
gem "rspec-rails", "~> 3.5", ">= 3.5.2"
gem "rubocop", "~> 0.77.0"
gem "rubocop-performance", "~> 1.5", ">= 1.5.1"
gem "rubocop-rails", "~> 2.4"
end

group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem "listen", ">= 3.0.5", "< 3.2"
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
end

group :test do
gem 'capybara'
gem 'webmock', '~> 3.1'
gem 'vcr', '~> 5.1'
gem 'codeclimate-test-reporter', '~> 1.0.0'
gem 'simplecov'
gem 'shoulda-matchers', '~> 4.1', '>= 4.1.2'
gem 'rubocop-rspec', '~> 1.28'
gem 'faker'
gem 'factory_bot_rails', '~> 4.8', '>= 4.8.2'
gem "capybara"
gem "codeclimate-test-reporter", "~> 1.0.0"
gem "factory_bot_rails", "~> 4.8", ">= 4.8.2"
gem "faker"
gem "rubocop-rspec", "~> 1.28"
gem "shoulda-matchers", "~> 4.1", ">= 4.1.2"
gem "simplecov"
gem "vcr", "~> 5.1"
gem "webmock", "~> 3.1"
end
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
2 changes: 1 addition & 1 deletion app/controllers/concerns/facetable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def facet_by_year(arr)

def facet_by_provider(arr)
# generate hash with id and name for each provider in facet
ids = arr.map { |hsh| hsh["key"] }.join(",")
ids = arr.pluck("key").join(",")
providers = Provider.find_by(ids: ids).to_a.reduce({}) do |sum, p|
sum[p.id] = p.name
sum
Expand Down
8 changes: 4 additions & 4 deletions app/jobs/report_import_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ class ReportImportJob < ApplicationJob

def perform(item, options = {})
response = UsageUpdate.get_data(item, options)
if response.status != 200
Rails.logger.error "[Usage Report Parsing] Report #{item} not found"
{}
else
if response.status == 200
# report = Report.new(response, options)
Rails.logger.debug "[Usage Report] Started to parse #{item}."
UsageUpdate.redirect(response)
# case report.get_type
# when "normal" then Report.parse_normal_report report
# when "compressed" then Report.parse_multi_subset_report report
# end
else
Rails.logger.error "[Usage Report Parsing] Report #{item} not found"
{}
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/usage_update_parse_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def perform(dataset, options)

def send_message(data, item, _options = {})
errors = data.select { |hsh| hsh.fetch("errors", nil) }
if data.length.zero?
if data.empty?
# options[:level] = "warning"
Rails.logger.error "[Usage Report Parsing] Error parsing Report #{item}. Report is empty"
elsif !errors.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/models/affiliation_identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def self.push_item(item)
def self.get_ror_metadata(id)
return {} if id.blank?

url = "https://api.ror.org/organizations/#{id[8..-1]}"
url = "https://api.ror.org/organizations/#{id[8..]}"
response = Maremma.get(url, host: true)
return {} if response.status != 200

Expand Down
8 changes: 3 additions & 5 deletions app/models/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,9 @@ def self.parse_datacite_metadata(id: nil, response: nil)
"name" => attributes["publisher"] }
end
proxy_identifiers = Array.wrap(attributes["relatedIdentifiers"]).select do |ri|
["IsVersionOf", "IsIdenticalTo", "IsPartOf",
"IsSupplementTo"].include?(ri["relationType"])
end.map do |ri|
ri["relatedIdentifier"]
end
["IsVersionOf", "IsIdenticalTo", "IsPartOf",
"IsSupplementTo"].include?(ri["relationType"])
end.pluck("relatedIdentifier")
resource_type_general = attributes.dig("types", "resourceTypeGeneral")
type = Bolognese::Utils::DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] # || attributes.dig("types", "schemaOrg")

Expand Down
6 changes: 3 additions & 3 deletions app/models/concerns/importable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def normalize_arxiv(id)
id = id.downcase

# turn arXiv into a URL if needed
id = "https://arxiv.org/abs/#{id[6..-1]}" if id.start_with?("arxiv:")
id = "https://arxiv.org/abs/#{id[6..]}" if id.start_with?("arxiv:")

# check for valid protocol.
uri = Addressable::URI.parse(id)
Expand All @@ -97,7 +97,7 @@ def normalize_igsn(id)
return nil unless uri&.host && %w(http https).include?(uri.scheme)

# don't use IGSN resolver as no support for ssl
id = "https://hdl.handle.net/10273/#{id[15..-1]}" if id.start_with?("http://igsn.org")
id = "https://hdl.handle.net/10273/#{id[15..]}" if id.start_with?("http://igsn.org")

# clean up URL
PostRank::URI.clean(id.downcase)
Expand Down Expand Up @@ -129,7 +129,7 @@ def normalize_pmid(id)
id = id.downcase

# strip pmid prefix
id = id[5..-1] if id.start_with?("pmid:")
id = id[5..] if id.start_with?("pmid:")

# turn handle into a URL if needed
id = "https://identifiers.org/pubmed:#{id}" unless id.start_with?("http")
Expand Down
2 changes: 1 addition & 1 deletion app/models/orcid_affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def self.push_item(item)
def self.get_ror_metadata(id)
return {} if id.blank?

url = "https://api.ror.org/organizations/#{id[8..-1]}"
url = "https://api.ror.org/organizations/#{id[8..]}"
response = Maremma.get(url, host: true)
return {} if response.status != 200

Expand Down
4 changes: 2 additions & 2 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
load Gem.bin_path("bundler", "bundle")
10 changes: 5 additions & 5 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
load File.expand_path("spring", __dir__)
rescue LoadError => e
raise unless e.message.include?('spring')
raise unless e.message.include?("spring")
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
8 changes: 4 additions & 4 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
load File.expand_path("spring", __dir__)
rescue LoadError => e
raise unless e.message.include?('spring')
raise unless e.message.include?("spring")
end
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
19 changes: 9 additions & 10 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
require "pathname"
require "fileutils"
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -14,22 +14,21 @@ chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end

puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! "bin/rails db:setup"

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end
8 changes: 4 additions & 4 deletions bin/spring
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# It gets overwritten when you run the `spring binstub` command.

unless defined?(Spring)
require 'rubygems'
require 'bundler'
require "rubygems"
require "bundler"

lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == "spring" }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
gem "spring", spring.version
require "spring/binstub"
end
end
18 changes: 9 additions & 9 deletions bin/update
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
require "pathname"
require "fileutils"
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -14,16 +14,16 @@ chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

puts "\n== Updating database =="
system! 'bin/rails db:migrate'
system! "bin/rails db:migrate"

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
require_relative "config/environment"

run Rails.application
2 changes: 1 addition & 1 deletion config/initializers/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
DOI_FORMAT = %r(\A10\.\d{4,5}/.+).freeze

# Format used for URL validation
URL_FORMAT = %r(\A(http|https|ftp)://[a-z0-9]+([\-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?/.*)?\z).freeze
URL_FORMAT = %r(\A(http|https|ftp)://[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?/.*)?\z).freeze

# Form queue options
QUEUE_OPTIONS = ["high", "default", "low"].freeze
Expand Down
Loading

0 comments on commit a0a12d8

Please sign in to comment.