foodcoops/foodsoft

View on GitHub

Showing 133 of 181 total issues

Method received has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def received(data)
    mail = Mail.new data

    mail_part = get_mail_part(mail)
    raise 'No valid content could be found' if mail_part.nil?
Severity: Minor
Found in plugins/messages/app/mail_receivers/messages_mail_receiver.rb - About 55 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

Method verify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def verify(message)
    r = super(message)
    raise InvalidMessage unless r.is_a?(Array) && r.length >= 2 && r.length <= 3
    raise InvalidScope unless r[0] == FoodsoftConfig.scope
    raise InvalidPrefix unless r[1] == @_prefix
Severity: Minor
Found in app/lib/token_verifier.rb - About 55 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

Method find_match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_match(category)
    return if category.blank? || category.length < 3

    c = nil
    ## exact match - not needed, will be returned by next query as well
Severity: Minor
Found in app/models/article_category.rb - About 45 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

Method uniqueness_of_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def uniqueness_of_name
    matches = Article.where(name: name, supplier_id: supplier_id, deleted_at: deleted_at, type: type)
    matches = matches.where.not(id: id) unless new_record?
    # supplier should always be there - except, perhaps, on initialization (on seeding)
    if supplier && (supplier.shared_sync_method.blank? || supplier.shared_sync_method == 'import')
Severity: Minor
Found in app/models/article.rb - About 45 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

Method index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    sort = if params['sort']
             case params['sort']
             when 'date' then 'created_on'
             when 'note'   then 'note'
Severity: Minor
Found in app/controllers/finance/financial_transactions_controller.rb - About 45 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

Method group_id= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def group_id=(group_id)
    group = Group.find(group_id) if group_id.present?
    if group
      @send_method = 'workgroup' if group.type == 'Workgroup'
      @send_method = 'ordergroup' if group.type == 'Ordergroup'
Severity: Minor
Found in plugins/messages/app/models/message.rb - About 45 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

Method add_financial_transaction! has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def add_financial_transaction!(amount, note, user, transaction_type, link = nil, group_order = nil)
Severity: Minor
Found in app/models/ordergroup.rb - About 45 mins to fix

    Method get_mail_part has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_mail_part(mail)
        return mail unless mail.multipart?
    
        mail_part = nil
        for part in mail.parts
    Severity: Minor
    Found in plugins/messages/app/mail_receivers/messages_mail_receiver.rb - About 45 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

    Method close! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def close!(user, transaction_type = nil, financial_link = nil, create_foodcoop_transaction: false)
        raise I18n.t('orders.model.error_closed') if closed?
    
        update_price_of_group_orders!
    
    
    Severity: Minor
    Found in app/models/order.rb - About 45 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

    Avoid deeply nested control flow statements.
    Open

              case type
              when :groups
                total += goa.result * goa.order_article.price.fc_price
              when :groups_without_markup
                total += goa.result * goa.order_article.price.gross_price
    Severity: Major
    Found in app/models/order.rb - About 45 mins to fix

      Method accept_invitation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def accept_invitation
          @invite = Invite.find_by_token(params[:token])
          if @invite.nil? || @invite.expires_at < Time.now
            redirect_to login_url, alert: I18n.t('login.controller.error_invite_invalid')
          elsif @invite.group.nil?
      Severity: Minor
      Found in app/controllers/login_controller.rb - About 45 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

      Method []= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def []=(key, value)
            return false unless allowed_key?(key)
      
            value = normalize_value value
            # then update database
      Severity: Minor
      Found in app/lib/foodsoft_config.rb - About 45 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

      Method authenticate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def authenticate(role = 'any')
          # Attempt to retrieve authenticated user from controller instance or session...
          if current_user
            # We have an authenticated user, now check role...
            # Roles gets the user through his memberships.
      Severity: Minor
      Found in app/controllers/concerns/auth.rb - About 45 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

      Method show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          link = Link.find(params[:id])
          url = link.url
      
          return deny_access if link.workgroup && !current_user.role_admin? && !link.workgroup.member?(current_user)
      Severity: Minor
      Found in plugins/links/app/controllers/links_controller.rb - About 45 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

      Method link_to_ordering has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def link_to_ordering(order, options = {}, &block)
          group_order = order.group_order(current_user.ordergroup)
          path = if options[:show] && group_order
                   group_order_path(group_order)
                 elsif group_order
      Severity: Minor
      Found in app/helpers/group_orders_helper.rb - About 45 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

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

        def index
          sort = if params['sort']
                   case params['sort']
                   when 'name' then 'articles.name'
                   when 'unit' then 'articles.unit'
      Severity: Minor
      Found in app/controllers/articles_controller.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

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

        def create
          order = Order.find(params[:order])
          state = order.open? ? 'queued' : 'ready'
          count = 0
          PrinterJob.transaction do
      Severity: Minor
      Found in plugins/printer/app/controllers/printer_jobs_controller.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

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

        def user_list=(ids)
          list = ids.split(',').map(&:to_i)
          new_users = (list - users.collect(&:id)).uniq
          old_users = users.reject { |user| list.include?(user.id) }
      
      
      Severity: Minor
      Found in app/models/task.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

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

        def self.parse(file, options = {})
          filepath = file.is_a?(String) ? file : file.to_path
          filename = options.delete(:filename) || filepath
          fileext = File.extname(filename)
          options[:csv_options] = { col_sep: ';', encoding: 'utf-8' }.merge(options[:csv_options] || {})
      Severity: Minor
      Found in app/lib/spreadsheet_file.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

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

        def show
          @doc_options ||= {}
          @order_ids = if params[:id]
                         params[:id].split('+').map(&:to_i)
                       else

      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

      Severity
      Category
      Status
      Source
      Language