From bd2366e4afd09c48fb94e679d975af7015754425 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 21 Oct 2018 03:37:01 -0700 Subject: [PATCH] Simplify. --- .../CSharpUseIndexOperatorDiagnosticAnalyzer.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Features/CSharp/Portable/UseIndexOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/UseIndexOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs index 530c062122d..3155a958357 100644 --- a/src/Features/CSharp/Portable/UseIndexOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/UseIndexOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs @@ -113,14 +113,10 @@ protected override void InitializeWorker(AnalysisContext context) } // Arg needs to be a subtraction for: `s.Length - value` + // And left side of the subtraction needs to be `s.Length` var arg = propertyReference.Arguments[0]; - if (!IsSubtraction(arg, out var subtraction)) - { - return; - } - - // Left side of the subtraction needs to be `s.Length` - if (!IsInstanceLengthCheck(lengthLikeProperty, propertyReference.Instance, subtraction.LeftOperand)) + if (!IsSubtraction(arg, out var subtraction) || + !IsInstanceLengthCheck(lengthLikeProperty, propertyReference.Instance, subtraction.LeftOperand)) { return; } -- GitLab