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
  • GroovyGroovy
  • 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
Groovy

Groovy static code analysis

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

  • All rules 21
  • Bug5
  • Code Smell16
 
Tags
    Impact
      Clean code attribute
        1. GString expressions should not be used as map keys

           Bug
        2. "@TimedInterrupt" should not be used on static methods

           Bug
        3. Null checks should use correct logical operators

           Bug
        4. Classes with a "clone()" method should implement "Cloneable"

           Bug
        5. "wait()" calls should be inside "while" loops

           Bug

        "wait()" calls should be inside "while" loops

        intentionality - logical
        reliability
        maintainability
        Bug
        • multi-threading

        This rule raises an issue when a call to Object.wait() is not within a while loop.

        Why is this an issue?

        How can I fix it?

        More Info

        Calls to Object.wait() should always be placed inside while loops to handle two critical concurrency scenarios properly.

        First, the Java Virtual Machine can produce spurious wakeups. This means that a thread waiting on a condition can be awakened even when the condition has not actually been satisfied. If the wait() call is inside an if statement, the thread will proceed after the spurious wakeup without rechecking the condition, potentially leading to incorrect behavior.

        Second, race conditions can occur when multiple threads are involved. Between the time a condition is checked and the wait() method is called, another thread might change the condition. If the condition was satisfied by another thread before wait() is invoked, the current thread could wait indefinitely for a condition that has already been met.

        Using a while loop ensures that the condition is rechecked immediately after the thread wakes up, providing protection against both spurious wakeups and race conditions.

        What is the potential impact?

        When wait() calls are not properly guarded by while loops, applications can experience:

        • Deadlocks: Threads may wait indefinitely for conditions that have already been satisfied
        • Data corruption: Threads may proceed with operations when the required conditions are not actually met
        • Unpredictable behavior: Spurious wakeups can cause threads to execute code at inappropriate times
        • Race conditions: Multiple threads may interfere with each other’s execution in unexpected ways

        These issues are particularly difficult to debug because they may occur intermittently and depend on timing and thread scheduling.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2026 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use