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: 1 rule found
error-handling
    Impact
      Clean code attribute
        1. Bare rescue clauses should specify exception types

           Code Smell

        Bare rescue clauses should specify exception types

        intentionality - complete
        maintainability
        Code Smell
        • exception
        • error-handling

        Why is this an issue?

        How can I fix it?

        More Info

        Bare rescue clauses without specifying an exception class catch all StandardError exceptions. This creates several problems:

        Hidden bugs: Unexpected errors get silently caught and handled the same way as expected ones. A typo in your code might raise a NameError, but your bare rescue will catch it and treat it like a normal business exception.

        Difficult debugging: When something goes wrong, you won’t know what actually failed. The original error gets masked by generic error handling.

        Unclear intent: Other developers (including future you) can’t tell what exceptions you intended to handle. This makes the code harder to maintain and modify safely.

        Ruby’s exception hierarchy means that rescue without a class catches StandardError and all its subclasses. This includes common exceptions like ArgumentError, NoMethodError, and RuntimeError that usually indicate programming mistakes rather than expected conditions.

        Being explicit about which exceptions to catch makes your code more robust and easier to debug.

        What is the potential impact?

        Bare rescue clauses can hide critical bugs and make applications harder to debug and maintain. Unexpected errors may be silently swallowed, leading to incorrect application behavior that’s difficult to trace and fix.

          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