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] "avoid-wrapping-in-padding" reacts to named and factory constructors that have no padding in their parameters #1001
Closed
Description
- Dart code metrics version: 4.17.1
- Dart sdk version: ">=2.18.0 <3.0.0"
Configuration
analyzer:
plugins:
- dart_code_metrics
dart_code_metrics:
metrics-exclude:
- test/**
rules-exclude:
- test/**
anti-patterns:
- long-method
- long-parameter-list
metrics:
cyclomatic-complexity: 20
maintainability-index: 50
maximum-nesting: 5
number-of-parameters: 5
source-lines-of-code: 50
technical-debt:
threshold: 1
todo-cost: 4
ignore-cost: 8
ignore-for-file-cost: 16
as-dynamic-cost: 16
deprecated-annotations-cost: 2
file-nullsafety-migration-cost: 2
unit-type: "hours"
rules:
- avoid-global-state
- avoid-nested-conditional-expressions:
acceptable-level: 2
- avoid-non-null-assertion
- avoid-unused-parameters
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-global-state
- binary-expression-operand-order
- double-literal-format
- newline-before-return
- no-boolean-literal-compare
- no-empty-block
- no-equal-then-else
- no-magic-number
- no-object-declaration
- prefer-conditional-expressions
- prefer-correct-type-name
- prefer-first
- prefer-last
- always-remove-listener
- avoid-returning-widgets
- avoid-unnecessary-setstate
- avoid-wrapping-in-padding
- prefer-const-border-radius
- prefer-extracting-callbacks
What did you do? Please include the source code example causing the issue.
import 'package:flutter/material.dart';
void main() {
runApp(CoolWidget());
}
class CoolWidget extends StatelessWidget {
const CoolWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
// lint
const Padding(
padding: EdgeInsets.all(10),
child: Test.named(),
),
// lint
Padding(
padding: const EdgeInsets.all(10),
child: Test.factory(),
),
// OK
const Test(padding: EdgeInsets.all(10))
],
);
}
}
class Test extends StatelessWidget {
const Test({
Key? key,
this.padding = const EdgeInsets.all(8.0),
}) : super(key: key);
const Test.named() : padding = const EdgeInsets.all(9.0);
factory Test.factory() => const Test();
final EdgeInsetsGeometry padding;
@override
Widget build(BuildContext context) {
return const SizedBox();
}
}
What did you expect to happen?
I don't expect to see a warning from a lint
What actually happened?
I get a warning from lint on Padding: avoid-wrapping-in-padding
Are you willing to submit a pull request to fix this bug?
Yes, if I can find the time.