Skip to content

Commit

Permalink
Add Rails config to Rubocop linter
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Mar 14, 2023
1 parent 9b3854b commit e92d4d1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require:
- rubocop-rails

AllCops:
Exclude:
- "Gemfile"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ gem "capistrano", "~> 3.17"
gem "capistrano-bundler", "~> 2.1"

gem "capistrano-rvm", "~> 0.1.2"

gem 'rubocop-rails', '~> 2.18'
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-rails (2.18.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
Expand Down Expand Up @@ -247,6 +251,7 @@ DEPENDENCIES
rails-controller-testing (~> 1.0)
responders (~> 3.0)
rubocop (~> 1.36)
rubocop-rails (~> 2.18)
stathat (~> 0.1.7)
tzinfo-data

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def taxa2tree
# param[names]: "true" or "false", Include the lineage names
def taxonomy
@result = @query.where(id: @input)
@result = Hash[@result.map { |t| [t.id, t] }]
@result = @result.index_by(&:id)
@input_order = @input.select { |i| @result.key? i.to_i }
@result = @input_order.map { |i| @result[i.to_i] }
respond_with(@result)
Expand Down
2 changes: 1 addition & 1 deletion app/models/peptide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Peptide < ApplicationRecord

belongs_to :uniprot_entry
belongs_to :sequence
belongs_to :original_sequence, foreign_key: 'original_sequence_id', primary_key: 'id', class_name: 'Sequence'
belongs_to :original_sequence, primary_key: 'id', class_name: 'Sequence'

# since this is a read-only model, these validations aren't used
validates :sequence_id, presence: true
Expand Down
12 changes: 6 additions & 6 deletions app/models/uniprot_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class UniprotEntry < ApplicationRecord
has_many :go_terms, through: :go_cross_references
has_many :interpro_entries, through: :interpro_cross_references

belongs_to :taxon, foreign_key: 'taxon_id',
primary_key: 'id',
class_name: 'Taxon'
belongs_to :taxon,
primary_key: 'id',
class_name: 'Taxon'

belongs_to :lineage, foreign_key: 'taxon_id',
primary_key: 'taxon_id',
Expand Down Expand Up @@ -63,7 +63,7 @@ def self.summarize_fa(entries)
GoCrossReference
.where(uniprot_entry_id: id_batch)
.all
.each do |cr|
.find_each do |cr|
ups_with_go.add(cr.uniprot_entry_id)
# Also count in how many proteins this GO term occurs
data[cr.go_term_code] += 1
Expand All @@ -77,7 +77,7 @@ def self.summarize_fa(entries)
EcCrossReference
.where(uniprot_entry_id: id_batch)
.all
.each do |cr|
.find_each do |cr|
ups_with_ec.add(cr.uniprot_entry_id)
# Also count in how many proteins this EC number occurs
data["EC:#{cr.ec_number_code}"] += 1
Expand All @@ -91,7 +91,7 @@ def self.summarize_fa(entries)
InterproCrossReference
.where(uniprot_entry_id: id_batch)
.all
.each do |cr|
.find_each do |cr|
ups_with_ipr.add(cr.uniprot_entry_id)
data["IPR:#{cr.interpro_entry_code}"] += 1
end
Expand Down

0 comments on commit e92d4d1

Please sign in to comment.