denny/ShinyCMS-ruby

View on GitHub

Showing 9 of 658 total issues

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

      def add_element( formatting, name )
        return add_long_text_element name if formatting == 'simple_format'
        return add_html_element name      if formatting == 'sanitize'
        return add_image_element name     if formatting == 'image_tag' || name.include?( 'image' )

Severity: Minor
Found in plugins/ShinyCMS/app/public/models/concerns/shinycms/template.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Confirmed

    def index
      authenticate_user! unless params[:token]

      if subscriber
        @subscriptions = subscriber.subscriptions

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 check_with_akismet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_with_akismet
      return true if user_signed_in?
      return true unless akismet_api_key_is_set? && feature_enabled?( :akismet_for_comments )

      spam, blatant = akismet_check( request, @new_comment )
Severity: Minor
Found in plugins/ShinyCMS/app/controllers/shinycms/comments_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 selected_comment_ids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Confirmed

    def selected_comment_ids
      comment_ids = []
      update_params[ :spam_comments ].each_pair do |key, value|
        next unless value == '1'

Severity: Minor
Found in plugins/ShinyCMS/app/controllers/shinycms/admin/comments_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

Avoid too many return statements within this method.
Confirmed

      return false unless user.admin?
Severity: Major
Found in plugins/ShinyCMS/app/models/shinycms/feature_flag.rb - About 30 mins to fix

    Method update_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Confirmed

        def update_value( id, params )
          setting = Setting.find( id )
    
          return false if setting.level == 'site'
          return false if setting.level == 'admin' && current_user_is_not_admin?
    Severity: Minor
    Found in plugins/ShinyCMS/app/controllers/shinycms/site_settings_controller.rb - About 25 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 enabled? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Confirmed

        def self.enabled?( name, user = nil )
          feature = find_by( name: name.to_s )
    
          return false if feature.blank?
          return true  if feature.enabled?
    Severity: Minor
    Found in plugins/ShinyCMS/app/models/shinycms/feature_flag.rb - About 25 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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Confirmed

        def perform( send )
          return unless send.sendable?
    
          send.mark_as_sending
    
    
    Severity: Minor
    Found in plugins/ShinyNewsletters/app/jobs/shiny_newsletters/send_to_list_job.rb - About 25 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 seed_setting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def seed_setting( name:, value: '', description: nil, level: 'site', locked: false )
          setting = ShinyCMS::Setting.find_or_create_by!( name: name.to_s )
          setting.unlock
    
          setting.update!( description: description ) if description.present?
    Severity: Minor
    Found in plugins/ShinyCMS/app/public/lib/shinycms/seeder.rb - About 25 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