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
Filtered: 2 rules found
confusing
    Impact
      Clean code attribute
        1. Range methods should be used appropriately to avoid unexpected behavior

           Code Smell
        2. Method names should not use reserved keywords

           Code Smell

        Range methods should be used appropriately to avoid unexpected behavior

        intentionality - clear
        reliability
        maintainability
        Code Smell
        • confusing

        This is an issue when using containsWithinBounds() instead of contains() for membership testing.

        Why is this an issue?

        How can I fix it?

        More Info

        Groovy Range objects have subtle but important differences in their methods that can lead to unexpected behavior if misused.

        The containsWithinBounds() method only checks if a value falls between the range boundaries, while contains() checks if the value is actually part of the discrete items in the range. For example, with the range 1.5..3, the value 2 falls within the bounds but is not actually in the range, since the range contains [1.5, 2.5], incrementing by one from 1.5. Using containsWithinBounds(2) returns true, but contains(2) correctly returns false.

        What is the potential impact?

        Using the wrong Range method can cause logic errors in conditional statements, leading to incorrect program behavior.

          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