JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Third-Party Included

Kotlin Warning Classes Corresponding to detekt Rules

This page describes the CodeSonar warning classes that are assigned to Kotlin warnings imported from a SARIF file produced by detekt.

See also the table of CodeSonar warning classes that are supported for all languages. If these classes are enabled, the corresponding CodeSonar checks will include all Kotlin source files that were imported into the project with codesonar kotlin_scan.py, codesonar import_sarif.py, or codesonar add_source_files.py.



Introduction

This page describes the CodeSonar warning classes that are assigned to Kotlin warnings imported from a SARIF file produced by detekt.

For information on setting up your CodeSonar project to incorporate Kotlin source code and the corresponding detekt results, see Including Kotlin Components in a CodeSonar Project.

Kotlin Warning Classes from detekt rules

When CodeSonar imports a SARIF file, it determines a corresponding CodeSonar warning class for each rule object in the SARIF rules. If a given warning class does not already exist, the SARIF importer creates it.

There is special handling for SARIF files produced by detekt.

detekt-specific handling for warning class names and categories

CodeSonar Warning Property Value
Name Generated from the name property of the rule object (which in turn matches a detekt rule name) as follows.
  • The camel case name is transformed to space-separated title case.
    This includes transforming minor words such as "or" and "and" to lower-case.
  • " (detekt)" is appended to the resulting string.
    This greatly reduces the chance of collision with warning class names from other sources, which is important because warning class Name is a unique identifier. It also provides a ready mechanism for visually and programmatically identifying CodeSonar warnings that originate from detekt results.
Categories When a warning class is based on a Rust Clippy lint, its categories depend on whether the warning class is built in to CodeSonar or created by the SARIF importer.
  • In both cases, the class has a category of the form detekt:<setname>.<rulename>
    detekt.<setname>.<rulename> is the id property of the rule object.
  • For built-in classes only, there is also a warning class mnemonic: KOTLIN.<set>.<abbr>
    <set> is based on the detekt rule set and <abbr> is an abbreviation of the class Name.
otherwise Other warning class properties are not set by the SARIF importer.

Example

Suppose the imported SARIF file includes a rule object like the following.

# ...
    "rules":[
        # ...
      {
        "id": "detekt.style.MagicNumber",
        "name": "MagicNumber",
        # ...
      },
      # ...
    ], 
# ...

(This corresponds to the detekt MagicNumber rule.)

  1. CodeSonar computes the corresponding warning class name: "Magic Number (detekt)".
  2. If there is not already a warning class with this name, CodeSonar creates the warning class. The class categories will be
  3. CodeSonar creates a "Magic Number (detekt)" warning instance for each result entry in the SARIF that has "ruleId": "detekt.style.MagicNumber".

CodeSonar will consider a SARIF file to be produced by detekt in the following cases.

SARIF files produced by detekt

CodeSonar will consider a SARIF file to be produced by detekt in the following cases.

Built-In Kotlin Warning Classes

These warning classes correspond to rules from detekt version v1.23.8.

Class Name Mnemonic
Absent or Wrong File License (detekt) KOTLIN.COMMENTS.AOWFL
Also Could Be Apply (detekt) KOTLIN.STYLE.ACBA
Array Primitive (detekt) KOTLIN.PERFORMANCE.AP
Avoid Referential Equality (detekt) KOTLIN.BUGS.ARE
Boolean Property Naming (detekt) KOTLIN.NAMING.BPN
Braces on If Statements (detekt) KOTLIN.STYLE.BOIS
Braces on When Statements (detekt) KOTLIN.STYLE.BOWS
Can Be Non Nullable (detekt) KOTLIN.STYLE.CBNN
Cascading Call Wrapping (detekt) KOTLIN.STYLE.CCW
Cast Nullable to Non Nullable Type (detekt) KOTLIN.BUGS.CNTNNT
Cast to Nullable Type (detekt) KOTLIN.BUGS.CTNT
Class Naming (detekt) KOTLIN.NAMING.CN
Class Ordering (detekt) KOTLIN.STYLE.CO
Cognitive Complex Method (detekt) KOTLIN.COMPLEXITY.COGCM
Collapsible If Statements (detekt) KOTLIN.STYLE.CIS
Comment Over Private Function (detekt) KOTLIN.COMMENTS.COPF
Comment Over Private Property (detekt) KOTLIN.COMMENTS.COPP
Complex Condition (detekt) KOTLIN.COMPLEXITY.CC
Complex Interface (detekt) KOTLIN.COMPLEXITY.CI
Constructor Parameter Naming (detekt) KOTLIN.NAMING.CPN
Could Be Sequence (detekt) KOTLIN.PERFORMANCE.CBS
Cyclomatic Complex Method (detekt) KOTLIN.COMPLEXITY.CYCCM
Data Class Contains Functions (detekt) KOTLIN.STYLE.DCCF
Data Class Should Be Immutable (detekt) KOTLIN.STYLE.DCSBI
Deprecated Block Tag (detekt) KOTLIN.COMMENTS.DBT
Deprecation (detekt) KOTLIN.BUGS.DEPRECATION
Destructuring Declaration With Too Many Entries (detekt) KOTLIN.STYLE.DDWTME
Dont Downcast Collection Types (detekt) KOTLIN.BUGS.DDCT
Double Mutability for Collection (detekt) KOTLIN.BUGS.DMFC
Double Negative Lambda (detekt) KOTLIN.STYLE.DNL
Else Case Instead of Exhaustive When (detekt) KOTLIN.BUGS.ECIOEW
Empty Catch Block (detekt) KOTLIN.EMPTY-BLOCKS.ECTCHB
Empty Class Block (detekt) KOTLIN.EMPTY-BLOCKS.ECLSB
Empty Default Constructor (detekt) KOTLIN.EMPTY-BLOCKS.EDC
Empty Do While Block (detekt) KOTLIN.EMPTY-BLOCKS.EDWB
Empty Else Block (detekt) KOTLIN.EMPTY-BLOCKS.EEB
Empty Finally Block (detekt) KOTLIN.EMPTY-BLOCKS.EFINB
Empty Function Block (detekt) KOTLIN.EMPTY-BLOCKS.EFUNB
Empty If Block (detekt) KOTLIN.EMPTY-BLOCKS.EIFB
Empty Init Block (detekt) KOTLIN.EMPTY-BLOCKS.EINITB
Empty Kt File (detekt) KOTLIN.EMPTY-BLOCKS.EKF
Empty Secondary Constructor (detekt) KOTLIN.EMPTY-BLOCKS.ESC
Empty Try Block (detekt) KOTLIN.EMPTY-BLOCKS.ETB
Empty When Block (detekt) KOTLIN.EMPTY-BLOCKS.EWHENB
Empty While Block (detekt) KOTLIN.EMPTY-BLOCKS.EWHILEB
Empty for Block (detekt) KOTLIN.EMPTY-BLOCKS.EFORB
End of Sentence Format (detekt) KOTLIN.COMMENTS.EOSF
Enum Naming (detekt) KOTLIN.NAMING.EN
Equals Always Returns True or False (detekt) KOTLIN.BUGS.EARTOF
Equals Null Call (detekt) KOTLIN.STYLE.ENC
Equals With Hash Code Exist (detekt) KOTLIN.BUGS.EWHCE
Equals on Signature Line (detekt) KOTLIN.STYLE.EOSL
Exception Raised in Unexpected Location (detekt) KOTLIN.EXCEPTIONS.ERIUL
Exit Outside Main (detekt) KOTLIN.BUGS.EOM
Explicit Collection Element Access Method (detekt) KOTLIN.STYLE.ECEAM
Explicit Garbage Collection Call (detekt) KOTLIN.BUGS.EGCC
Explicit It Lambda Parameter (detekt) KOTLIN.STYLE.EILP
Expression Body Syntax (detekt) KOTLIN.STYLE.EBS
For Each on Range (detekt) KOTLIN.PERFORMANCE.FEOR
Forbidden Annotation (detekt) KOTLIN.STYLE.FA
Forbidden Class Name (detekt) KOTLIN.NAMING.FCN
Forbidden Comment (detekt) KOTLIN.STYLE.FC
Forbidden Import (detekt) KOTLIN.STYLE.FI
Forbidden Method Call (detekt) KOTLIN.STYLE.FMC
Forbidden Suppress (detekt) KOTLIN.STYLE.FS
Forbidden Void (detekt) KOTLIN.STYLE.FV
Function Max Length (detekt) KOTLIN.NAMING.FMAXL
Function Min Length (detekt) KOTLIN.NAMING.FMINL
Function Naming (detekt) KOTLIN.NAMING.FN
Function Only Returning Constant (detekt) KOTLIN.STYLE.FORC
Function Parameter Naming (detekt) KOTLIN.NAMING.FPN
Global Coroutine Usage (detekt) KOTLIN.COROUTINES.GCU
Has Platform Type (detekt) KOTLIN.BUGS.HPT
Ignored Return Value (detekt) KOTLIN.BUGS.IRV
Implicit Default Locale (detekt) KOTLIN.BUGS.IDL
Implicit Unit Return Type (detekt) KOTLIN.BUGS.IURT
Inject Dispatcher (detekt) KOTLIN.COROUTINES.ID
Instance of Check for Exception (detekt) KOTLIN.EXCEPTIONS.IOCFE
Invalid Package Declaration (detekt) KOTLIN.NAMING.IPD
Invalid Range (detekt) KOTLIN.BUGS.IR
Iterator Has Next Calls Next Method (detekt) KOTLIN.BUGS.IHNCNM
Iterator Not Throwing No Such Element Exception (detekt) KOTLIN.BUGS.INTNSEE
KDoc References Non Public Property (detekt) KOTLIN.COMMENTS.KDRNPP
Labeled Expression (detekt) KOTLIN.COMPLEXITY.LE
Lambda Parameter Naming (detekt) KOTLIN.NAMING.LPN
Large Class (detekt) KOTLIN.COMPLEXITY.LC
Lateinit Usage (detekt) KOTLIN.BUGS.LU
Long Method (detekt) KOTLIN.COMPLEXITY.LM
Long Parameter List (detekt) KOTLIN.COMPLEXITY.LPL
Loop With Too Many Jump Statements (detekt) KOTLIN.STYLE.LWTMJS
Magic Number (detekt) KOTLIN.STYLE.MN
Mandatory Braces Loops (detekt) KOTLIN.STYLE.MBL
Map Get With Not Null Assertion Operator (detekt) KOTLIN.BUGS.MGWNNAO
Matching Declaration Name (detekt) KOTLIN.NAMING.MDN
Max Chained Calls on Same Line (detekt) KOTLIN.STYLE.MCCOSL
Max Line Length (detekt) KOTLIN.STYLE.MLL
May Be Const (detekt) KOTLIN.STYLE.MBC
Member Name Equals Class Name (detekt) KOTLIN.NAMING.MNECN
Method Overloading (detekt) KOTLIN.COMPLEXITY.MO
Missing Package Declaration (detekt) KOTLIN.BUGS.MPD
Modifier Order (detekt) KOTLIN.STYLE.MO
Multiline Lambda It Parameter (detekt) KOTLIN.STYLE.MLIP
Multiline Raw String Indentation (detekt) KOTLIN.STYLE.MRSI
Named Arguments (detekt) KOTLIN.COMPLEXITY.NA
Nested Block Depth (detekt) KOTLIN.COMPLEXITY.NBD
Nested Classes Visibility (detekt) KOTLIN.STYLE.NCV
Nested Scope Functions (detekt) KOTLIN.COMPLEXITY.NSF
New Line at End of File (detekt) KOTLIN.STYLE.NLAEOF
No Name Shadowing (detekt) KOTLIN.NAMING.NNS
No Tabs (detekt) KOTLIN.STYLE.NT
Non Boolean Property Prefixed With Is (detekt) KOTLIN.NAMING.NBPPWI
Not Implemented Declaration (detekt) KOTLIN.EXCEPTIONS.NID
Null Check on Mutable Property (detekt) KOTLIN.BUGS.NCOMP
Nullable Boolean Check (detekt) KOTLIN.STYLE.NBC
Nullable to String Call (detekt) KOTLIN.BUGS.NTSC
Object Extends Throwable (detekt) KOTLIN.EXCEPTIONS.OET
Object Literal to Lambda (detekt) KOTLIN.STYLE.OLTL
Object Property Naming (detekt) KOTLIN.NAMING.OPN
Optional Abstract Keyword (detekt) KOTLIN.STYLE.OAK
Optional Unit (detekt) KOTLIN.STYLE.OU
Outdated Documentation (detekt) KOTLIN.COMMENTS.OD
Package Naming (detekt) KOTLIN.NAMING.PN
Prefer to Over Pair Syntax (detekt) KOTLIN.STYLE.PTOPS
Print Stack Trace (detekt) KOTLIN.EXCEPTIONS.PST
Property Used Before Declaration (detekt) KOTLIN.BUGS.PUBD
Protected Member in Final Class (detekt) KOTLIN.STYLE.PMIFC
Redundant Explicit Type (detekt) KOTLIN.STYLE.RET
Redundant Higher Order Map Usage (detekt) KOTLIN.STYLE.RHOMU
Redundant Suspend Modifier (detekt) KOTLIN.COROUTINES.RSM
Redundant Visibility Modifier Rule (detekt) KOTLIN.STYLE.RVMR
Replace Safe Call Chain With Run (detekt) KOTLIN.COMPLEXITY.RSCCWR
Rethrow Caught Exception (detekt) KOTLIN.EXCEPTIONS.RCE
Return Count (detekt) KOTLIN.STYLE.RC
Return From Finally (detekt) KOTLIN.EXCEPTIONS.RFF
Safe Cast (detekt) KOTLIN.STYLE.SC
Serial Version UIDIn Serializable Class (detekt) KOTLIN.STYLE.SVUIDISC
Sleep Instead of Delay (detekt) KOTLIN.COROUTINES.SIOD
Spacing Between Package and Imports (detekt) KOTLIN.STYLE.SBPAI
Spread Operator (detekt) KOTLIN.PERFORMANCE.SO
String Literal Duplication (detekt) KOTLIN.COMPLEXITY.SLD
String Should Be Raw String (detekt) KOTLIN.STYLE.SSBRS
Suspend Fun Swallowed Cancellation (detekt) KOTLIN.COROUTINES.SFSC
Suspend Fun With Coroutine Scope Receiver (detekt) KOTLIN.COROUTINES.SFWCSR
Suspend Fun With Flow Return Type (detekt) KOTLIN.COROUTINES.SFWFRT
Swallowed Exception (detekt) KOTLIN.EXCEPTIONS.SE
Throwing Exception From Finally (detekt) KOTLIN.EXCEPTIONS.TEFF
Throwing Exception in Main (detekt) KOTLIN.EXCEPTIONS.TEIM
Throwing Exceptions Without Message or Cause (detekt) KOTLIN.EXCEPTIONS.TEWMOC
Throwing New Instance of Same Exception (detekt) KOTLIN.EXCEPTIONS.TNIOSE
Throws Count (detekt) KOTLIN.STYLE.TC
Too Generic Exception Caught (detekt) KOTLIN.EXCEPTIONS.TGEC
Too Generic Exception Thrown (detekt) KOTLIN.EXCEPTIONS.TGET
Too Many Functions (detekt) KOTLIN.COMPLEXITY.TMF
Top Level Property Naming (detekt) KOTLIN.NAMING.TLPN
Trailing Whitespace (detekt) KOTLIN.STYLE.TW
Trim Multiline Raw String (detekt) KOTLIN.STYLE.TMRS
Unconditional Jump Statement in Loop (detekt) KOTLIN.BUGS.UJSIL
Underscores in Numeric Literals (detekt) KOTLIN.STYLE.UINL
Undocumented Public Class (detekt) KOTLIN.COMMENTS.UPC
Undocumented Public Function (detekt) KOTLIN.COMMENTS.UPF
Undocumented Public Property (detekt) KOTLIN.COMMENTS.UPP
Unnecessary Abstract Class (detekt) KOTLIN.STYLE.UAC
Unnecessary Annotation Use Site Target (detekt) KOTLIN.STYLE.UAUST
Unnecessary Apply (detekt) KOTLIN.STYLE.UA
Unnecessary Backticks (detekt) KOTLIN.STYLE.UB
Unnecessary Braces Around Trailing Lambda (detekt) KOTLIN.STYLE.UBATL
Unnecessary Filter (detekt) KOTLIN.STYLE.UF
Unnecessary Inheritance (detekt) KOTLIN.STYLE.UINH
Unnecessary Inner Class (detekt) KOTLIN.STYLE.UIC
Unnecessary Let (detekt) KOTLIN.STYLE.UNL
Unnecessary Not Null Check (detekt) KOTLIN.BUGS.UNNC
Unnecessary Not Null Operator (detekt) KOTLIN.BUGS.UNNO
Unnecessary Parentheses (detekt) KOTLIN.STYLE.UNP
Unnecessary Part of Binary Expression (detekt) KOTLIN.PERFORMANCE.UPOBE
Unnecessary Safe Call (detekt) KOTLIN.BUGS.USC
Unnecessary Temporary Instantiation (detekt) KOTLIN.PERFORMANCE.UTI
Unreachable Catch Block (detekt) KOTLIN.BUGS.UCB
Unreachable Code (detekt) KOTLIN.BUGS.UCODE
Unsafe Call on Nullable Type (detekt) KOTLIN.BUGS.UCONT
Unsafe Cast (detekt) KOTLIN.BUGS.USCAST
Until Instead of Range to (detekt) KOTLIN.STYLE.UIORT
Unused Imports (detekt) KOTLIN.STYLE.UUIMP
Unused Parameter (detekt) KOTLIN.STYLE.UUPARAM
Unused Private Class (detekt) KOTLIN.STYLE.UPC
Unused Private Member (detekt) KOTLIN.STYLE.UPM
Unused Private Property (detekt) KOTLIN.STYLE.UPP
Unused Unary Operator (detekt) KOTLIN.BUGS.UUO
Use Any or None Instead of Find (detekt) KOTLIN.STYLE.UAONIOF
Use Array Literals in Annotations (detekt) KOTLIN.STYLE.UALIA
Use Check Not Null (detekt) KOTLIN.STYLE.UCNN
Use Check or Error (detekt) KOTLIN.STYLE.UCOE
Use Data Class (detekt) KOTLIN.STYLE.UDC
Use Empty Counterpart (detekt) KOTLIN.STYLE.UEC
Use If Empty or If Blank (detekt) KOTLIN.STYLE.UIEOIB
Use If Instead of When (detekt) KOTLIN.STYLE.UIIOW
Use Is Null or Empty (detekt) KOTLIN.STYLE.UINOE
Use Let (detekt) KOTLIN.STYLE.USELET
Use Require (detekt) KOTLIN.STYLE.UR
Use Require Not Null (detekt) KOTLIN.STYLE.URNN
Use Sum of Instead of Flat Map Size (detekt) KOTLIN.STYLE.USOIOFMS
Use or Empty (detekt) KOTLIN.STYLE.UOE
Useless Call on Not Null (detekt) KOTLIN.STYLE.UCONN
Useless Postfix Expression (detekt) KOTLIN.BUGS.UPE
Utility Class With Public Constructor (detekt) KOTLIN.STYLE.UCWPC
Var Could Be Val (detekt) KOTLIN.STYLE.VCBV
Variable Max Length (detekt) KOTLIN.NAMING.VMAXL
Variable Min Length (detekt) KOTLIN.NAMING.VMINL
Variable Naming (detekt) KOTLIN.NAMING.VN
Wildcard Import (detekt) KOTLIN.STYLE.WI
Wrong Equals Type Parameter (detekt) KOTLIN.BUGS.WETP

Enabling and Disabling

You have multiple degrees of control over reporting for the warnings issued by detekt.

 

To report problems with this documentation, please visit https://support.codesecure.com/.