@@ -404,10 +404,10 @@ impl Abc for JavaCode {
404404 }
405405 GT | LT => {
406406 // Excludes `<` and `>` used for generic types
407- if let Some ( parent) = node. parent ( ) {
408- if !matches ! ( parent. kind_id( ) . into( ) , TypeArguments ) {
409- stats . conditions += 1. ;
410- }
407+ if let Some ( parent) = node. parent ( )
408+ && !matches ! ( parent. kind_id( ) . into( ) , TypeArguments )
409+ {
410+ stats . conditions += 1. ;
411411 }
412412 }
413413 // Counts unary conditions in elements separated by `&&` or `||` boolean operators
@@ -423,31 +423,31 @@ impl Abc for JavaCode {
423423 // Counts unary conditions inside assignments
424424 VariableDeclarator | AssignmentExpression => {
425425 // The child node of index 2 contains the right operand of an assignment operation
426- if let Some ( right_operand) = node. child ( 2 ) {
427- if matches ! (
426+ if let Some ( right_operand) = node. child ( 2 )
427+ && matches ! (
428428 right_operand. kind_id( ) . into( ) ,
429429 ParenthesizedExpression | UnaryExpression
430- ) {
431- java_inspect_container ( & right_operand , & mut stats . conditions ) ;
432- }
430+ )
431+ {
432+ java_inspect_container ( & right_operand , & mut stats . conditions ) ;
433433 }
434434 }
435435 // Counts unary conditions inside if and while statements
436436 IfStatement | WhileStatement => {
437437 // The child node of index 1 contains the condition
438- if let Some ( condition) = node. child ( 1 ) {
439- if matches ! ( condition. kind_id( ) . into( ) , ParenthesizedExpression ) {
440- java_inspect_container ( & condition , & mut stats . conditions ) ;
441- }
438+ if let Some ( condition) = node. child ( 1 )
439+ && matches ! ( condition. kind_id( ) . into( ) , ParenthesizedExpression )
440+ {
441+ java_inspect_container ( & condition , & mut stats . conditions ) ;
442442 }
443443 }
444444 // Counts unary conditions do-while statements
445445 DoStatement => {
446446 // The child node of index 3 contains the condition
447- if let Some ( condition) = node. child ( 3 ) {
448- if matches ! ( condition. kind_id( ) . into( ) , ParenthesizedExpression ) {
449- java_inspect_container ( & condition , & mut stats . conditions ) ;
450- }
447+ if let Some ( condition) = node. child ( 3 )
448+ && matches ! ( condition. kind_id( ) . into( ) , ParenthesizedExpression )
449+ {
450+ java_inspect_container ( & condition , & mut stats . conditions ) ;
451451 }
452452 }
453453 // Counts unary conditions inside for statements
@@ -487,25 +487,25 @@ impl Abc for JavaCode {
487487 // Counts unary conditions inside return statements
488488 ReturnStatement => {
489489 // The child node of index 1 contains the return value
490- if let Some ( value) = node. child ( 1 ) {
491- if matches ! (
490+ if let Some ( value) = node. child ( 1 )
491+ && matches ! (
492492 value. kind_id( ) . into( ) ,
493493 ParenthesizedExpression | UnaryExpression
494- ) {
495- java_inspect_container ( & value , & mut stats . conditions )
496- }
494+ )
495+ {
496+ java_inspect_container ( & value , & mut stats . conditions )
497497 }
498498 }
499499 // Counts unary conditions inside implicit return statements in lambda expressions
500500 LambdaExpression => {
501501 // The child node of index 2 contains the return value
502- if let Some ( value) = node. child ( 2 ) {
503- if matches ! (
502+ if let Some ( value) = node. child ( 2 )
503+ && matches ! (
504504 value. kind_id( ) . into( ) ,
505505 ParenthesizedExpression | UnaryExpression
506- ) {
507- java_inspect_container ( & value , & mut stats . conditions )
508- }
506+ )
507+ {
508+ java_inspect_container ( & value , & mut stats . conditions )
509509 }
510510 }
511511 // Counts unary conditions inside ternary expressions
@@ -523,22 +523,22 @@ impl Abc for JavaCode {
523523 }
524524 }
525525 // The child node of index 2 contains the first expression
526- if let Some ( expression) = node. child ( 2 ) {
527- if matches ! (
526+ if let Some ( expression) = node. child ( 2 )
527+ && matches ! (
528528 expression. kind_id( ) . into( ) ,
529529 ParenthesizedExpression | UnaryExpression
530- ) {
531- java_inspect_container ( & expression , & mut stats . conditions ) ;
532- }
530+ )
531+ {
532+ java_inspect_container ( & expression , & mut stats . conditions ) ;
533533 }
534534 // The child node of index 4 contains the second expression
535- if let Some ( expression) = node. child ( 4 ) {
536- if matches ! (
535+ if let Some ( expression) = node. child ( 4 )
536+ && matches ! (
537537 expression. kind_id( ) . into( ) ,
538538 ParenthesizedExpression | UnaryExpression
539- ) {
540- java_inspect_container ( & expression , & mut stats . conditions ) ;
541- }
539+ )
540+ {
541+ java_inspect_container ( & expression , & mut stats . conditions ) ;
542542 }
543543 }
544544 _ => { }
0 commit comments