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
runtime-error
    Impact
      Clean code attribute
        1. Rails API controllers using "respond_to" should include "ActionController::MimeResponds"

           Bug

        Rails API controllers using "respond_to" should include "ActionController::MimeResponds"

        intentionality - complete
        reliability
        maintainability
        Bug
        • rails
        • api
        • runtime-error

        This is an issue when a Rails API controller uses the respond_to method without including the ActionController::MimeResponds module.

        Why is this an issue?

        How can I fix it?

        More Info

        Rails API controllers inherit from ActionController::API, which is a lightweight version of ActionController::Base. Unlike the full controller, ActionController::API does not include MIME response functionality by default.

        The respond_to method is part of the ActionController::MimeResponds module, which provides content negotiation capabilities. When you use respond_to in an API controller without including this module, Rails cannot find the method and raises a NoMethodError at runtime.

        This error typically occurs when developers migrate from full Rails controllers to API-only controllers, or when they follow examples that assume the full controller functionality is available. The error message can be confusing because Ruby suggests respond_to? (the Object method for checking if an object responds to a method) instead of the missing respond_to method.

        What is the potential impact?

        This issue causes a runtime NoMethodError that will crash the application when the affected controller action is called. This leads to:

        • Application downtime and poor user experience
        • Failed API requests that clients cannot handle gracefully
        • Potential data loss if the error occurs during critical operations
        • Debugging time spent tracking down what appears to be a missing method
          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