Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

[BUG] async*/yield Stream building function triggers avoid-redundant-async #1017

Closed
@pitazzo

Description

@pitazzo
  • Dart code metrics version: 4.19.1
  • Dart sdk version: 2.18.2

Please show your full configuration:

Configuration
include: package:flutter_lints/flutter.yaml

linter:
  rules:
    constant_identifier_names: false
    prefer_single_quotes: true
    sort_pub_dependencies: true

analyzer:
  plugins:
    - dart_code_metrics
  exclude:
    - test/**/*.dart

dart_code_metrics:
  anti-patterns:
    - long-method
  metrics:
    cyclomatic-complexity: 20
    maximum-nesting-level: 5
    number-of-parameters: 4
    source-lines-of-code: 50
  metrics-exclude:
    - test/**
    - lib/injector.config.dart
  rules-exclude:
    - lib/injector.config.dart
  rules:
    - always-remove-listener
    - avoid-border-all
    - avoid-collection-methods-with-unrelated-types
    - avoid-dynamic
    - avoid-global-state
    - avoid-late-keyword
    - avoid-missing-enum-constant-in-map
    - avoid-nested-conditional-expressions
    - avoid-redundant-async
    - avoid-throw-in-catch-block
    - avoid-top-level-members-in-tests
    - avoid-unnecessary-type-assertions
    - avoid-unnecessary-type-casts
    - avoid-unused-parameters
    - binary-expression-operand-order
    - double-literal-format
    - member-ordering-extended:
        order:
          - public-fields
          - private-fields
          - constructors
          - public-getters
          - private-getters
          - public-methods
          - private-methods
    - no-boolean-literal-compare
    - no-empty-block
    - no-equal-arguments
    - no-equal-then-else
    - no-object-declaration
    - prefer-async-await
    - prefer-commenting-analyzer-ignores
    - prefer-conditional-expressions
    - prefer-correct-identifier-length:
        exceptions:
          - i
          - x
          - y
          - z
    - prefer-correct-test-file-name
    - prefer-correct-type-name:
        max-length: 44
    - prefer-enums-by-name
    - prefer-first
    - prefer-immediate-return
    - prefer-iterable-of
    - prefer-last
    - prefer-match-file-name
    - prefer-moving-to-variable
    - prefer-trailing-comma

What did you do? Please include the source code example causing the issue.
I have used the async*/yield syntax to build a stream

  Stream<int> buildStream() async* {
    for (int i = 0; i < 10; i++) {
      yield i;
    }
  }

What did you expect to happen?
As the async*keyword is mandatory to create such streams, I expected no rule to be reported.

What actually happened?
avoid-redundant-async rules was reported.

Are you willing to submit a pull request to fix this bug?
Would love to do so, but I think I don't have the time nor the expertise to do it.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions