catarse/catarse

View on GitHub

Showing 134 of 134 total issues

Function CatarseAnalytics has a Cognitive Complexity of 159 (exceeds 5 allowed). Consider refactoring.
Open

window.CatarseAnalytics = window.CatarseAnalytics || (function(){
    /*!
   * cookie-monster - a simple cookie library
   * v0.3.0
   * https://github.com/jgallen23/cookie-monster
Severity: Minor
Found in app/assets/javascripts/analytics.js - About 3 days 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

File common_wrapper.rb has 709 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class CommonWrapper
  attr_accessor :api_key

  def services_endpoint
    @services_endpoint ||= {
Severity: Major
Found in app/models/common_wrapper.rb - About 1 day to fix

    Function CatarseAnalytics has 284 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    window.CatarseAnalytics = window.CatarseAnalytics || (function(){
        /*!
       * cookie-monster - a simple cookie library
       * v0.3.0
       * https://github.com/jgallen23/cookie-monster
    Severity: Major
    Found in app/assets/javascripts/analytics.js - About 1 day to fix

      File project.rb has 556 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Project < ActiveRecord::Base
        include I18n::Alchemy
        PUBLISHED_STATES = %w[online waiting_funds successful failed].freeze
        HEADLINE_MAXLENGTH = 100
        NAME_MAXLENGTH = 50
      Severity: Major
      Found in app/models/project.rb - About 1 day to fix

        Class Project has 63 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Project < ActiveRecord::Base
          include I18n::Alchemy
          PUBLISHED_STATES = %w[online waiting_funds successful failed].freeze
          HEADLINE_MAXLENGTH = 100
          NAME_MAXLENGTH = 50
        Severity: Major
        Found in app/models/project.rb - About 1 day to fix

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

          class User < ActiveRecord::Base
            include I18n::Alchemy
            acts_as_token_authenticatable
            include User::OmniauthHandler
            include Shared::CommonWrapper
          Severity: Major
          Found in app/models/user.rb - About 7 hrs to fix

            File user.rb has 429 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class User < ActiveRecord::Base
              include I18n::Alchemy
              acts_as_token_authenticatable
              include User::OmniauthHandler
              include Shared::CommonWrapper
            Severity: Minor
            Found in app/models/user.rb - About 6 hrs to fix

              Class ProjectsController has 35 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class ProjectsController < ApplicationController
                after_filter :verify_authorized, except: %i[show index video video_embed embed embed_panel about_mobile]
                after_filter :redirect_user_back_after_login, only: %i[index show]
                before_action :authorize_and_build_resources, only: %i[edit]
              
              Severity: Minor
              Found in app/controllers/projects_controller.rb - About 4 hrs to fix

                Class CommonWrapper has 33 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class CommonWrapper
                  attr_accessor :api_key
                
                  def services_endpoint
                    @services_endpoint ||= {
                Severity: Minor
                Found in app/models/common_wrapper.rb - About 4 hrs to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def index_project_post(resource)
                      return unless resource.id.present?
                      unless resource.project.common_id.present?
                        resource.project.index_on_common
                        resource.project.reload
                  Severity: Major
                  Found in app/models/common_wrapper.rb and 1 other location - About 3 hrs to fix
                  app/models/common_wrapper.rb on lines 651..692

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 126.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def index_goal(resource)
                      return unless resource.id.present?
                      unless resource.project.common_id.present?
                        resource.project.index_on_common
                        resource.project.reload
                  Severity: Major
                  Found in app/models/common_wrapper.rb and 1 other location - About 3 hrs to fix
                  app/models/common_wrapper.rb on lines 606..648

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 126.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                  class Contribution < ActiveRecord::Base
                    has_notifications
                  
                    include I18n::Alchemy
                    include PgSearch
                  Severity: Minor
                  Found in app/models/contribution.rb - About 3 hrs to fix

                    File analytics.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    //evitamos criar duas vezes...
                    //tem q ser não dependente de outros codigos
                    window.CatarseAnalytics = window.CatarseAnalytics || (function(){
                        /*!
                       * cookie-monster - a simple cookie library
                    Severity: Minor
                    Found in app/assets/javascripts/analytics.js - About 2 hrs to fix

                      Method index_contribution has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def index_contribution(resource)
                          return unless resource.id.present?
                          unless resource.project.common_id.present?
                            resource.project.index_on_common
                            resource.project.reload
                      Severity: Minor
                      Found in app/models/common_wrapper.rb - 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

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

                      class UsersController < ApplicationController
                        after_filter :verify_authorized, except: %i[reactivate]
                        after_filter :redirect_user_back_after_login, only: %i[show]
                        inherit_resources
                        defaults finder: :find_active!
                      Severity: Minor
                      Found in app/controllers/users_controller.rb - About 2 hrs to fix

                        Function _event has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function _event(eventObj, fn, ignoreGA) {
                            if (eventObj) {
                              try {
                                var project = eventObj.project||_getProject(),
                                    user = eventObj.user||_getUser();
                        Severity: Major
                        Found in app/assets/javascripts/analytics.js - About 2 hrs to fix

                          File projects_controller.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          class InvalidProject < StandardError; end
                          class SuccessfulProject < StandardError; end
                          class ProjectsController < ApplicationController
                            after_filter :verify_authorized, except: %i[show index video video_embed embed embed_panel about_mobile]
                            after_filter :redirect_user_back_after_login, only: %i[index show]
                          Severity: Minor
                          Found in app/controllers/projects_controller.rb - About 2 hrs to fix

                            Method to_csv has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def self.to_csv
                                attributes = [
                                        'Nome completo',
                                        'Nome público',
                                        'CPF',
                            Severity: Major
                            Found in app/models/subscription_monthly_report_for_project_owner.rb - About 2 hrs to fix

                              Class ApplicationController has 22 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                              class ApplicationController < ActionController::Base
                                EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
                                include Concerns::ExceptionHandler
                                include Concerns::SocialHelpersHandler
                                include Concerns::AnalyticsHelpersHandler
                              Severity: Minor
                              Found in app/controllers/application_controller.rb - About 2 hrs to fix

                                Method update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def update
                                    authorize resource
                                
                                    # need to check this before setting new attributes
                                    should_validate = should_use_validate
                                Severity: Minor
                                Found in app/controllers/projects_controller.rb - 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

                                Severity
                                Category
                                Status
                                Source
                                Language