fairmondo/fairmondo

View on GitHub

Showing 48 of 56 total issues

Class User has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ApplicationRecord
  extend Memoist
  extend Tokenize
  extend RailsAdminStatistics

Severity: Minor
Found in app/models/user.rb - About 5 hrs to fix

    Class Statistic has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Statistic
      def statistics_category_articles c
        a = Article.new(categories: [c])
        articles = a.find_like_this(1)
        articles.total
    Severity: Minor
    Found in app/models/statistic.rb - About 4 hrs to fix

      Class ArticlesController has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ArticlesController < ApplicationController
        include ArticleControllerFilters
        include ArticleParams
      
        respond_to :html
      Severity: Minor
      Found in app/controllers/articles_controller.rb - About 3 hrs to fix

        Class MassUploadArticle has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class MassUploadArticle < ApplicationRecord
          belongs_to :article
          belongs_to :mass_upload
          has_one :user, through: :mass_upload
          default_scope { order('row_index ASC') }
        Severity: Minor
        Found in app/models/mass_upload_article.rb - About 2 hrs to fix

          Function generateTOC has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function generateTOC() {
            if ($('#filecontents').length === 0) return;
            var _toc = $('<ol class="top"></ol>');
            var show = false;
            var toc = _toc;
          Severity: Major
          Found in doc/js/app.js - About 2 hrs to fix

            Function searchItem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            function searchItem() {
              for (var i = 0; i < searchCache.length / 50; i++) {
                var item = searchCache[searchIndex];
                var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
                var matchString = regexSearchString;
            Severity: Minor
            Found in doc/js/full_list.js - About 2 hrs 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

            Function fullListSearch has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function fullListSearch() {
              // generate cache
              searchCache = [];
              $('#full_list li').each(function() {
                var link = $(this).find('.object_link a');
            Severity: Minor
            Found in doc/js/full_list.js - About 1 hr to fix

              Method attributes_for has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def attributes_for(user)
                  attributes = {
                    customer_type: user.is_a?(LegalEntity) ? 'business' : 'consumer',
                    organization: (user.is_a?(LegalEntity) &&
                                   user.standard_address_company_name.present?) ?
              Severity: Minor
              Found in app/services/fastbill_api.rb - About 1 hr to fix

                Method article_attributes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.article_attributes
                    %w(
                      € id title categories condition condition_extra
                      content quantity price_cents basic_price_cents
                      basic_price_amount vat external_title_image_url image_2_url
                Severity: Minor
                Found in app/models/mass_upload.rb - About 1 hr to fix

                  Method validate_each has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def validate_each(record, attribute, value)
                      range = options[:in]
                      value ||= []
                      value = [value] unless value.respond_to?(:size) # fix for existing entries
                      unless options[:allow_blank_entries]
                  Severity: Minor
                  Found in app/validators/size_validator.rb - About 1 hr 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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def update
                      super
                  
                      if current_user.present?
                        # TODO: Remove duplicate code in passwords and sessions controllers
                  Severity: Minor
                  Found in app/controllers/passwords_controller.rb - About 1 hr 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

                  Function summaryToggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function summaryToggle() {
                    $('.summary_toggle').click(function() {
                      if (localStorage) {
                        localStorage.summaryCollapsed = $(this).text();
                      }
                  Severity: Minor
                  Found in doc/js/app.js - About 1 hr to fix

                    Method heart_button has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def heart_button(heartable_resource)
                        if user_signed_in?
                          heart = Heart.where(heartable: heartable_resource, user: current_user).limit 1
                        else
                          heart = Heart.where(heartable: heartable_resource, user_token: generate_user_token).limit 1
                    Severity: Minor
                    Found in app/helpers/hearts_helper.rb - About 1 hr to fix

                      Method revenue_last_month has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def revenue_last_month
                          revenue = 0
                          fair = 0
                          fee = 0
                      
                      
                      Severity: Minor
                      Found in app/models/statistic.rb - About 1 hr 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 validate_each has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def validate_each(record, attribute, selected_payment)
                          if record.is_a? BusinessTransaction
                            common_sense_error = common_sense_check selected_payment, record.selected_transport
                            record.errors[attribute] << common_sense_error if common_sense_error
                      
                      
                      Severity: Minor
                      Found in app/validators/common_sense_validator.rb - About 1 hr 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

                      Consider simplifying this complex logical expression.
                      Open

                            unless self.payment_bank_transfer || self.payment_paypal ||
                                  self.payment_cash || self.payment_cash_on_delivery ||
                                  self.payment_invoice || self.payment_voucher || self.payment_debit
                              errors.add(:payment_details, I18n.t('article.form.errors.invalid_payment_option'))
                            end
                      Severity: Major
                      Found in app/models/concerns/article_concerns/validations.rb - About 1 hr to fix

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

                          def fastbill_chain
                            @seller.with_lock do
                              if @seller.needs_to_be_billed?
                                unless @seller.has_fastbill_profile?
                                  fastbill_create_customer
                        Severity: Minor
                        Found in app/services/fastbill_api.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 visual_checkout_step has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def visual_checkout_step step, active, checked, link = nil
                            step_title = I18n.t("cart.steps.#{step}")
                            content_tag :span, class: "visual_checkout_step #{active ? 'active' : ''}" do
                              concat(content_tag(:i, '', class: (checked ? 'fa fa-check-square-o' : 'fa fa-square-o')))
                              concat(' ')
                        Severity: Minor
                        Found in app/helpers/checkout_helper.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_by_id_or_custom_seller_identifier has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def find_by_id_or_custom_seller_identifier
                            if IDENTIFIERS.select { |v| @article_attributes.include?(v) && @article_attributes[v].present? }.empty?
                              put_error I18n.t('mass_uploads.errors.no_identifier')
                              nil
                            else
                        Severity: Minor
                        Found in app/models/mass_upload_article.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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def show(range)
                            files_found = 0
                        
                            File.open('image_cleaner.txt', 'w') do |file|
                              for id in range
                        Severity: Minor
                        Found in app/services/image_cleaner.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

                        Severity
                        Category
                        Status
                        Source
                        Language