File tree Expand file tree Collapse file tree
python-checks/src/main/java/org/sonar/python/checks
python-frontend/src/test/java/org/sonar/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -372,30 +372,32 @@ private boolean tryParsingNestedField() {
372372 }
373373
374374 private boolean tryParseFlagCharacter (char current ) {
375- if (current == ':' ) {
376- state = FieldParseState .FORMAT ;
377- } else if (current == '}' ) {
378- addCurrentField ();
379- state = FieldParseState .FINISHED ;
380- } else {
381- parent .reportIssue (SYNTAX_ERROR_MESSAGE );
382- return false ;
375+ switch (current ) {
376+ case ':' -> state = FieldParseState .FORMAT ;
377+ case '}' -> {
378+ addCurrentField ();
379+ state = FieldParseState .FINISHED ;
380+ }
381+ default -> {
382+ parent .reportIssue (SYNTAX_ERROR_MESSAGE );
383+ return false ;
384+ }
383385 }
384-
385386 return true ;
386387 }
387388
388389 private boolean tryParseField (char current ) {
389- if (current == '!' ) {
390- state = FieldParseState .FLAG ;
391- } else if (current == ':' ) {
392- state = FieldParseState .FORMAT ;
393- } else if (current == '}' ) {
394- addCurrentField ();
395- state = FieldParseState .FINISHED ;
396- } else {
397- parent .reportIssue (SYNTAX_ERROR_MESSAGE );
398- return false ;
390+ switch (current ) {
391+ case '!' -> state = FieldParseState .FLAG ;
392+ case ':' -> state = FieldParseState .FORMAT ;
393+ case '}' -> {
394+ addCurrentField ();
395+ state = FieldParseState .FINISHED ;
396+ }
397+ default -> {
398+ parent .reportIssue (SYNTAX_ERROR_MESSAGE );
399+ return false ;
400+ }
399401 }
400402 return true ;
401403 }
Original file line number Diff line number Diff line change 2626import org .sonar .plugins .python .api .tree .QualifiedExpression ;
2727import org .sonar .plugins .python .api .tree .Tree ;
2828import org .sonar .python .PythonTestUtils ;
29- import org .sonar .python .types .InferredTypes ;
3029
3130import static org .assertj .core .api .Assertions .assertThat ;
3231import static org .sonar .python .PythonTestUtils .lastExpressionInFunction ;
Original file line number Diff line number Diff line change 2323import java .util .List ;
2424import java .util .Map ;
2525import java .util .Set ;
26- import java .util .stream .Collectors ;
2726import org .assertj .core .groups .Tuple ;
2827import org .junit .jupiter .api .AfterEach ;
2928import org .junit .jupiter .api .BeforeEach ;
You can’t perform that action at this time.
0 commit comments