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: 4 rules found
style
    Impact
      Clean code attribute
        1. Modules should use "extend self" instead of "module_function"

           Code Smell
        2. Array and hash literals should be used instead of constructors when no parameters are needed

           Code Smell
        3. Logical operators "and" and "or" should be replaced with "&&" and "||"

           Code Smell
        4. Explicit RuntimeErrors should be omitted in raise statements

           Code Smell

        Explicit RuntimeErrors should be omitted in raise statements

        consistency - conventional
        maintainability
        Code Smell
        • ruby
        • style

        This rule raises an issue when using the two-argument form of raise with an explicit RuntimeError class name.

        Why is this an issue?

        How can I fix it?

        More Info

        In Ruby, when you use the raise method with just a message string, it automatically raises a RuntimeError exception. This means that explicitly specifying RuntimeError as the exception class is redundant.

        The two-argument form raise RuntimeError, "message" and the single-argument form raise "message" produce exactly the same result. The explicit specification of RuntimeError adds unnecessary verbosity to your code without providing any additional functionality or clarity.

        Ruby’s design philosophy emphasizes conciseness and readability. By omitting the redundant RuntimeError, your code becomes more concise while maintaining the same behavior. This follows established Ruby style conventions and makes your code more idiomatic.

        The redundant specification can also make the code slightly harder to read, as developers need to process the extra information that doesn’t add value. Clean, concise code is generally easier to understand and maintain.

        What is the potential impact?

        This issue has minimal impact on functionality since both forms produce identical behavior. However, it affects code readability and maintainability by introducing unnecessary verbosity. Following consistent style conventions helps maintain clean, readable codebases that are easier for teams to work with.

          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