Skip to content

Flag two opposite conditions next to each other #57271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
filiph opened this issue Feb 16, 2016 · 8 comments
Closed

Flag two opposite conditions next to each other #57271

filiph opened this issue Feb 16, 2016 · 8 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-request type-enhancement A request for a change that isn't a bug

Comments

@filiph
Copy link
Contributor

filiph commented Feb 16, 2016

if (str[i] == '"') {
  while (i < str.length && str[i] != '"') {
    i += 1;
  }
}

The intent of this code is: if you encounter a double quote, skip all characters until you encounter another one.

It should be clear to the static analyzer that the while loop can never execute. (There should be another i += 1 before the while loop.)

@pq pq added type-enhancement A request for a change that isn't a bug linter-lint-request labels Feb 17, 2016
@alexeieleusis
Copy link
Contributor

This should be linted now that dart-archive/linter#229 is merged. I think it is not currently but fixing that should be easy. I might add a test to confirm @pq can you assign this to me?

@pq
Copy link
Member

pq commented Sep 13, 2016

I might add a test to confirm @pq can you assign this to me?

Once you accept the collaborator invite, you should be able to self-assign...

@filiph
Copy link
Contributor Author

filiph commented May 10, 2017

Is this linted? If so, we can close this bug.

Ideally, add the name of the lint here so people can find it through this bug.

@alexeieleusis
Copy link
Contributor

This should be linted by invariant_booleans.

@pq
Copy link
Member

pq commented May 11, 2017

@alexeieleusis : is there a test case that confirms it?

@alexeieleusis
Copy link
Contributor

@pq
Copy link
Member

pq commented May 11, 2017

Cool. Thanks @alexeieleusis ! Seems like this is safe to close?

@alexeieleusis
Copy link
Contributor

alexeieleusis commented May 11, 2017

I just saw the extra mutation condition, previous one with this https://github.com/dart-lang/linter/blob/master/test/rules/invariant_booleans.dart#L428 should provide the desired behavior.

@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants