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: 3 rules found
configuration
    Impact
      Clean code attribute
        1. Rails applications should define a root route with proper controller#action syntax

           Bug
        2. Environment variables should be validated or have default values

           Bug
        3. Asset compilation should be disabled in production environments

           Code Smell

        Environment variables should be validated or have default values

        intentionality - complete
        reliability
        maintainability
        Bug
        • configuration

        This rule raises an issue when environment variables are accessed directly using ENV["KEY"] without validation or default values, particularly in configuration contexts.

        Why is this an issue?

        How can I fix it?

        More Info

        Environment variables are external dependencies that may not be set in all environments. When you access an environment variable using ENV["KEY"], Ruby returns nil if the variable is not defined.

        This can lead to several problems:

        • Application startup failures: If critical configuration values are missing, your application may fail to start or behave unexpectedly.
        • Runtime errors: Methods that expect strings or other specific types may crash when receiving nil values.
        • Silent failures: Some APIs accept nil values but behave differently, leading to hard-to-debug issues.
        • Security vulnerabilities: Missing security-related configuration (like API keys or secrets) might cause authentication to fail silently or use insecure defaults.

        This is especially problematic in production environments where environment variables are the primary way to configure applications securely. A missing environment variable can cause immediate outages or security issues.

        What is the potential impact?

        Missing environment variables can cause application startup failures, runtime crashes, or security vulnerabilities. In production, this can lead to service outages or compromised authentication systems.

          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