SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
Ruby

Ruby static code analysis

Unique rules to find Bugs, Security Hotspots, and Code Smells in your RUBY code

  • All rules 75
  • Bug17
  • Security Hotspot2
  • Code Smell56
Filtered: 12 rules found
rails
    Impact
      Clean code attribute
        1. Private methods should be declared at the end of Ruby classes

           Code Smell
        2. Controllers should inherit from appropriate base classes

           Code Smell
        3. Rails model callback methods should be private

           Code Smell
        4. Rails collections should use "ids" instead of "pluck(:id)" for primary keys

           Code Smell
        5. Rails queries should use "find_by" instead of "where.take" for single record retrieval

           Code Smell
        6. HTTP status codes should use symbols instead of numeric values

           Code Smell
        7. Before destroy callbacks should use proper halt mechanism

           Bug
        8. Rails applications should define a root route with proper controller#action syntax

           Bug
        9. Rails API controllers using "respond_to" should include "ActionController::MimeResponds"

           Bug
        10. Asset compilation should be disabled in production environments

           Code Smell
        11. Global variables should not be used in Rails applications

           Code Smell
        12. ActiveRecord models should override "as_json" instead of "to_json" for custom JSON serialization

           Bug

        Rails applications should define a root route with proper controller#action syntax

        intentionality - logical
        reliability
        maintainability
        Bug
        • rails
        • routing
        • configuration

        This is an issue when a Rails application lacks a root route definition or uses incorrect controller#action syntax in route mappings.

        Why is this an issue?

        How can I fix it?

        More Info

        Rails applications require a root route to define the homepage that users see when they visit the base URL. Without a root route, users encounter routing errors when accessing the application’s main URL, which negatively impacts user experience, navigation, and SEO.

        Additionally, Rails routes must use proper controller#action syntax to map URLs to controller actions correctly. The root directive and custom route definitions require the controller#action format (e.g., 'posts#index') rather than path format (e.g., 'posts/index'). Incorrect syntax causes "Missing :action key" errors that prevent the application from starting.

        Proper routing is fundamental to Rails applications because:

        • The root route serves as the application’s entry point and homepage
        • Search engines and users expect a functional base URL
        • Incorrect route syntax breaks the application’s routing system entirely
        • Rails conventions depend on explicit controller#action mappings for non-RESTful routes

        What is the potential impact?

        Missing root routes cause 404 errors when users visit the application’s base URL, leading to poor user experience and reduced SEO rankings. Incorrect controller#action syntax prevents the Rails application from starting, causing complete application failure with "Missing :action key" errors during route loading.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use