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
Java

Java static code analysis

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

  • All rules 733
  • Vulnerability60
  • Bug175
  • Security Hotspot40
  • Code Smell458

  • Quick Fix 65
Filtered: 4 rules found
java22
    Impact
      Clean code attribute
        1. Types of unused record components should be removed from pattern matching

           Code Smell
        2. Unused exception parameter should use the unnamed variable pattern

           Code Smell
        3. Unnamed variable declarations should use the "var" identifier

           Code Smell
        4. Unused local variables should be removed

           Code Smell

        Unnamed variable declarations should use the "var" identifier

        intentionality - clear
        maintainability
        Code Smell
        • java22

        Why is this an issue?

        How can I fix it?

        More Info

        The syntax of some Java constructs, such as enhanced for loops, requires that you declare a variable that you may have no use for. To solve this issue, Java 22 introduced an unnamed variable pattern, _. This feature removes the need to name variables that are syntactically required but otherwise unused. Moreover, it clearly indicates the intent not to use the variable.

        To further minimize clutter, unnamed variables should use the var pattern rather than explicit type declarations. In addition to minimizing clutter, removing the type makes the code easier to maintain. Indeed, if the type was to change in future, the code would remain the same.

        Exceptions

        This rule does not apply to basic for loops and local variable declarations in a block.

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use