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

        Classes with a "clone()" method should implement "Cloneable"

        intentionality - complete
        reliability
        maintainability
        Bug

          This rule raises an issue when a class declares or overrides the clone() method but does not implement the Cloneable interface.

          Why is this an issue?

          How can I fix it?

          More Info

          The Cloneable interface serves as a marker interface that indicates a class supports cloning operations. When a class implements a clone() method without implementing Cloneable, it violates the established Java cloning contract.

          This violation can lead to several problems:

          • Runtime exceptions: If the clone() method calls super.clone() and the class doesn’t implement Cloneable, it will throw a CloneNotSupportedException at runtime.
          • Inconsistent behavior: Other developers and frameworks expect classes with clone() methods to implement Cloneable. Without it, the class may not work correctly with cloning utilities or frameworks.
          • Contract violation: The Java specification states that classes should implement Cloneable if they support cloning, making this a violation of the language contract.

          The Cloneable interface acts as a signal to the JVM and other code that the class has been designed to support cloning operations safely.

          What is the potential impact?

          Without implementing Cloneable, calling the clone() method may result in a CloneNotSupportedException at runtime, causing application crashes. This can lead to unexpected failures in production environments, especially when the cloning functionality is used indirectly through frameworks or libraries.

            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