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
C

C static code analysis

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

  • All rules 420
  • Vulnerability14
  • Bug111
  • Security Hotspot19
  • Code Smell276

  • Quick Fix 27
Filtered: 3 rules found
misra-directive
    Impact
      Clean code attribute
        1. A function call shall not violate the function's preconditions

           Bug
        2. Floating-point arithmetic should be used appropriately

           Bug
        3. Sections of code should not be "commented out"

           Code Smell

        A function call shall not violate the function's preconditions

        intentionality - logical
        reliability
        Bug
        • misra-c++2023
        • misra-required
        • misra-directive

        Why is this an issue?

        More Info

        This rule is part of MISRA C++:2023.

        Usage of this content is governed by Sonar’s terms and conditions. Redistribution is prohibited.

        Dir 0.3.2 - A function call shall not violate the function’s preconditions

        Category: Required

        Rationale

        Violating a function’s implicit or explicit preconditions may lead to it exhibiting unexpected results or having undefined behaviour.

        Example

        float f( float a )
        {
          return fmodf( a, 0.0f );      // 'fmodf' requires a non zero value
        }
        
        // Precondition for 'b1' is that 'v' is not empty
        int32_t b1( std::vector< int32_t > const & v )
        {
          return v.front ();
        }
        
        int32_t b2()
        {
          std::vector< int32_t > v;
        
          return b1( v );            // Violates the precondition of b1
        }
        

        Copyright The MISRA Consortium Limited © 2023

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use