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: 1 rule found
encoding
    Impact
      Clean code attribute
        1. File operations should specify charset encoding

           Code Smell

        File operations should specify charset encoding

        intentionality - complete
        reliability
        maintainability
        Code Smell
        • encoding

        This rule raises an issue when text-based file operations are performed without explicitly specifying a charset encoding.

        Why is this an issue?

        How can I fix it?

        More Info

        When reading from or writing to files containing text, the system uses a default charset encoding if none is specified. This default encoding varies between operating systems and system configurations:

        • Windows typically uses CP1252 or UTF-16
        • Linux and macOS typically use UTF-8
        • Some systems may use ISO-8859-1 or other encodings

        This creates several problems:

        Portability Issues: Code that works correctly on one system may fail or produce incorrect results on another system with a different default encoding.

        Data Corruption: Files containing non-ASCII characters (accented letters, symbols, emojis, or text in non-Latin scripts) may be read incorrectly or written in a way that corrupts the data.

        Silent Failures: Encoding issues often don’t cause immediate exceptions but instead produce garbled text that may only be noticed later in the application lifecycle.

        What is the potential impact?

        Files may be corrupted or misread when moved between systems with different default encodings. Non-ASCII characters may appear as question marks, boxes, or other garbled text. In severe cases, this can lead to data loss or application failures when processing international content.

          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