Skip to content

Commit

Permalink
Merge pull request #17 from unipept/fix/properly-configure-linting
Browse files Browse the repository at this point in the history
Properly configure RuboCop linter
  • Loading branch information
pverscha authored Mar 14, 2023
2 parents 872c6fe + 81dffab commit 56ebe48
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
10 changes: 10 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 All @@ -19,6 +22,13 @@ Style/ClassAndModuleChildren:
Style/FrozenStringLiteralComment:
Enabled: false

Rails/InverseOf:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
Rails/HelperInstanceVariable:
Enabled: false

# disable for now
Layout/LineLength:
Enabled: false
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
1 change: 0 additions & 1 deletion app/controllers/datasets_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class DatasetsController < HandleOptionsController
before_action :set_headers, only: %i[sampledata]
before_action :default_format_json, only: %i[sampledata]
before_action :authorize, only: %i[new edit create update destroy]

def sampledata
@datasets = Dataset.includes(:dataset_items).all
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 @@ -23,9 +23,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 @@ -60,7 +60,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 @@ -74,7 +74,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 @@ -88,7 +88,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 56ebe48

Please sign in to comment.