AgileVentures/LocalSupport

View on GitHub
app/models/organisation.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class has too many lines. [165/100]
Open

class Organisation < BaseOrganisation

  has_many :volunteer_ops
  has_many :users
  has_many :edits, class_name: 'ProposedOrganisationEdit', dependent: :destroy
Severity: Minor
Found in app/models/organisation.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class Organisation has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class Organisation < BaseOrganisation

  has_many :volunteer_ops
  has_many :users
  has_many :edits, class_name: 'ProposedOrganisationEdit', dependent: :destroy
Severity: Minor
Found in app/models/organisation.rb - About 3 hrs to fix

    Method has too many lines. [11/7] (https://github.com/bbatsov/ruby-style-guide#short-methods)
    Open

      def self.import(filename, limit, validation)
        csv_text = File.open(filename, 'r:ISO-8859-1')
        count = 0
        CSV.parse(csv_text, headers: true).each do |row|
          break if count >= limit
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method create_and_validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.create_and_validate(attributes)
        # create!(attributes.select{|k,v| !v.nil?})
        create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
      end
    Severity: Minor
    Found in app/models/organisation.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    TODO found
    Open

      accepts_nested_attributes_for :users # TODO check if needed
    Severity: Minor
    Found in app/models/organisation.rb by fixme

    Line is too long. [113/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          .having(organisation_id.count.eq category_ids.size) # and return the orgs with correct number of duplicates
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Replace class var @@column_mappings with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)
    Open

      @@column_mappings = {
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Line is too long. [122/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        error_msg = ('Error: Email is invalid' == error_msg) ? "The user email you entered,'#{email}', is invalid" : error_msg
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Ternary operators must not be nested. Prefer if or else constructs instead. (https://github.com/bbatsov/ruby-style-guide#no-nested-ternary)
    Open

        create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Line is too long. [93/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      # Alternative => :joins('LEFT OUTER JOIN users ON users.organisation_id = organisations.id)
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Line is too long. [134/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Line is too long. [95/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

            raise CSV::MalformedCSVError, "No expected column with name #{column_name} in CSV file"
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Line is too long. [124/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          .where(category_id.in category_ids)                 # at this point, orgs in multiple categories show up as duplicates
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    Line is too long. [96/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        create!(attributes.each { |k, v| attributes[k] = v.empty? ? 'NO INFORMATION RECORDED' : v })
    Severity: Minor
    Found in app/models/organisation.rb by rubocop

    There are no issues that match your filters.

    Category
    Status