diff --git a/rulesets/kotlin/jpinpoint-kotlin-rules.xml b/rulesets/kotlin/jpinpoint-kotlin-rules.xml index 005a701615..3dd9109682 100644 --- a/rulesets/kotlin/jpinpoint-kotlin-rules.xml +++ b/rulesets/kotlin/jpinpoint-kotlin-rules.xml @@ -227,26 +227,39 @@ class AvoidInMemoryStreamingDefaultConstructor { 1] +//FunctionBody[ + not(ancestor::FunctionDeclaration/SimpleIdentifier/T-Identifier[@Text='hashCode']) + and + count( + .//Assignment[ + .//(AssignmentAndOperator/T-ADD_ASSIGNMENT|AdditiveOperator/T-ADD) + and + (AssignableExpression|DirectlyAssignableExpression)//T-Identifier[ + (: property a string literal :) + @Text = ancestor::FunctionBody//PropertyDeclaration[ + ( + Expression[not(.//Expression)]//StringLiteral + (: explicit type String:) + or VariableDeclaration/Type//T-Identifier[@Text='String'] + (: assigned parameter of type String :) + or Expression[.//T-Identifier[@Text = ancestor::FunctionDeclaration/FunctionValueParameters/FunctionValueParameter[Parameter/Type//T-Identifier[@Text='String']]//T-Identifier/@Text]] + (: assigned non-nested function of explicit type String :) (: known issue: ignores parameters, may give false positives with overloaded methods :) + or Expression[.//T-Identifier[not(ancestor::CallSuffix)][@Text = ancestor::ClassMemberDeclarations//FunctionDeclaration[Type//T-Identifier[@Text='String']]//T-Identifier/@Text]] + ) + and not(Expression//T-Identifier[@Text='toMutableList']) + ]/VariableDeclaration//T-Identifier/@Text + ] + ] + ) > 1 +] //Statement[Assignment//(T-ADD_ASSIGNMENT|T-ADD)][position()=last()] - - ]]> + ]]> + + + + Kotlin hashCode numeric plus should not trigger AvoidMultipleConcatStatements + 0 + + + + + + + INACTIVE CHECK: hashCode with explicit String concatenation should be flagged + 0 + + + + \ No newline at end of file