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
RPG

RPG static code analysis

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

  • All rules 58
  • Vulnerability1
  • Bug7
  • Security Hotspot1
  • Code Smell49
Filtered: 3 rules found
suspicious
    Impact
      Clean code attribute
        1. Two branches in a conditional structure should not have exactly the same implementation

           Code Smell
        2. Identical expressions should not be used on both sides of a binary operator

           Bug
        3. Nested blocks of code should not be left empty

           Code Smell

        Two branches in a conditional structure should not have exactly the same implementation

        adaptability - distinct
        maintainability
        Code Smell
        • design
        • suspicious

        Why is this an issue?

        More Info

        When the same code is duplicated in two or more separate branches of a conditional, it can make the code harder to understand, maintain, and can potentially introduce bugs if one instance of the code is changed but others are not.

        Having two WHEN in the same SELECT statement or branches in the same IF structure with the same implementation is at best duplicate code, and at worst a coding error.

             C                   IF        X = 1
             C                   EXSR      SR01
             C                   EXSR      SR01
             C                   ELSEIF    X = 2
             C                   EXSR      SR02
             C                   ELSEIF    X = 3
             C                   EXSR      SR01                                         Noncompliant; duplicates first condition
             C                   EXSR      SR01
             C                   ENDIF
        
        select;
          when i = 1;
            doFirst();
            doSomething();
          when i = 2;
            doSomethingDifferent();
          when i = 3:  // Noncompliant; duplicates first when's implementation
            doFirst();
            doSomething();
        endsl;
        
        if (a >= 0 and a < 10);
          doFirst();
          doTheThing();
        elseif (a >= 10 and a < 20);
          doTheOtherThing();
        elseif (a >= 20 and a < 50);
          doFirst();       // Noncompliant; duplicates first condition
          doTheThing();
        else;
          doTheRest();
        endif;
        

        If the same logic is needed for both instances, they should be combined.

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Enterprise
          Edition
          Available Since
          9.1

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use