Skip to content
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

Chore/dcm lint #195

Merged
merged 8 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,48 @@ on:
branches: [main]

jobs:
test_mix_repo:
test:
runs-on: ubuntu-latest
name: Test Mix Repo
name: Test
steps:
- name: Checkout mix repo
uses: actions/checkout@v2
with:
path: main

- name: Checkout remix_ui repo
uses: actions/checkout@v2
with:
repository: conceptadev/remix_ui
path: remix

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"

- run: cd main && flutter pub get
- run: flutter pub get

- uses: axel-op/dart-package-analyzer@v3
- uses: invertase/github-action-dart-analyzer@v1
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: main
fatal-infos: false

- name: Install DCM
uses: CQLabs/setup-dcm@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Run DCM
run: dcm analyze lib --fatal-style --fatal-performance --fatal-warnings

# - name: Run DCM
# uses: CQLabs/dcm-action@v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# folders: lib
# pull_request_comment_on_fail: true


- run: flutter test

- run: cd main && flutter test

analyze_breaking_changes:
runs-on: ubuntu-latest
name: Analyze Breaking Changes

needs: test_mix_repo
needs: test
steps:
- name: Checkout mix repo
uses: actions/checkout@v2
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"andreasblech.better-tests",
"dart-code.dart-code",
"dcmdev.dcm-vscode-extension",
"flutterando.flutter-coverage"
"flutterando.flutter-coverage",
"dart-code.flutter",
"circlecodesolution.ccs-flutter-color"
]
}
48 changes: 18 additions & 30 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,53 +1,44 @@

include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "tool/**"
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
linter:
rules:
# TODO: Turn this to true when all public apis are documented
public_member_api_docs: false
prefer_relative_imports: true

analyzer:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"

dart_code_metrics:
extends:
- package:dart_code_metrics_presets/recommended.yaml
metrics-exclude:
- package:dart_code_metrics_presets/metrics_recommended.yaml
metrics-excludes:
- test/**
rules-exclude:
- "test/**"
rules:
# avoid-collection-mutating-methods: true
newline-before-return: true
avoid-importing-entrypoint-exports:
only-in-src: true
prefer-match-file-name: false
no-object-declaration: false
prefer-correct-callback-field-name: false
# Remove later when cleaning up
prefer-single-widget-per-file: false
parameters-ordering: false
# End of remove later
match-getter-setter-field-names: false
prefer-dedicated-media-query-methods: false
arguments-ordering:
child-last: true
avoid-dynamic: false
avoid-shadowing: false
prefer-getter-over-method: false
enum-constants-ordering: false
prefer-widget-private-members: false
prefer-static-class: false
avoid-late-keyword: false
avoid-declaring-call-method: false
avoid-long-parameter-list: false
avoid-recursive-calls: false
no-magic-number: false
avoid-ignoring-return-values: false
prefer-commenting-analyzer-ignores: false
prefer-correct-identifier-length: false
avoid-unsafe-collection-methods: false
avoid-similar-names: false
no-equal-arguments: false
prefer-prefixed-global-constants: false
avoid-returning-widgets: false
arguments-ordering:
child-last: true
avoid-nested-conditional-expressions:
acceptable-level: 3
member-ordering:
Expand All @@ -66,7 +57,4 @@ dart_code_metrics:
- overridden-public-getters
- build-method
prefer-named-boolean-parameters:
ignore-single: true



ignore-single: true
14 changes: 13 additions & 1 deletion lib/mix.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
library mix;

// This file is generated by the update_exports.dart script.
// DO NOT MODIFY MANUALLY

// Some default exports
export 'src/deprecations.dart';

// Automated file exports
export 'src/attributes/border/border_dto.dart';
export 'src/attributes/border/border_radius_dto.dart';
export 'src/attributes/border/border_radius_util.dart';
export 'src/attributes/border/border_util.dart';
export 'src/attributes/border/shape_border_dto.dart';
export 'src/attributes/border/shape_border_util.dart';
export 'src/attributes/color/color_directives.dart';
export 'src/attributes/color/color_dto.dart';
export 'src/attributes/color/color_util.dart';
export 'src/attributes/constraints/constraints_dto.dart';
export 'src/attributes/constraints/constraints_util.dart';
export 'src/attributes/decoration/decoration_dto.dart';
export 'src/attributes/decoration/decoration_util.dart';
export 'src/attributes/decoration/image/decoration_image_dto.dart';
export 'src/attributes/decoration/image/decoration_image_util.dart';
export 'src/attributes/gradient/gradient_dto.dart';
export 'src/attributes/gradient/gradient_util.dart';
export 'src/attributes/nested_style/nested_style_attribute.dart';
Expand All @@ -31,13 +43,13 @@ export 'src/core/attribute.dart';
export 'src/core/attributes_map.dart';
export 'src/core/decorator.dart';
export 'src/core/directive.dart';
export 'src/core/extensions/color_ext.dart';
export 'src/core/extensions/iterable_ext.dart';
export 'src/core/extensions/values_ext.dart';
export 'src/core/styled_widget.dart';
export 'src/decorators/widget_decorator_widget.dart';
export 'src/decorators/widget_decorators.dart';
export 'src/decorators/widget_decorators_util.dart';
export 'src/deprecations.dart';
export 'src/factory/mix_provider.dart';
export 'src/factory/mix_provider_data.dart';
export 'src/factory/style_mix.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/src/attributes/border/border_dto.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: prefer-returning-conditional-expressions

import 'package:flutter/material.dart';

import '../../core/attribute.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/src/attributes/border/border_radius_util.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: avoid-non-null-assertion

import 'package:flutter/material.dart';

import '../../core/attribute.dart';
Expand Down
5 changes: 4 additions & 1 deletion lib/src/attributes/border/shape_border_dto.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';

import '../../../mix.dart';
import '../../core/attribute.dart';
import '../../factory/mix_provider_data.dart';
import 'border_dto.dart';
import 'border_radius_dto.dart';

@immutable
abstract class ShapeBorderDto<Value extends ShapeBorder> extends Dto<Value>
Expand Down
7 changes: 6 additions & 1 deletion lib/src/attributes/border/shape_border_util.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'package:flutter/material.dart';

import '../../../mix.dart';
import '../../core/attribute.dart';
import '../scalars/scalar_util.dart';
import 'border_dto.dart';
import 'border_radius_dto.dart';
import 'border_radius_util.dart';
import 'border_util.dart';
import 'shape_border_dto.dart';

/// Utility for setting `ShapeBorder` values.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/attributes/color/color_util.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: avoid-non-null-assertion

import 'package:flutter/material.dart';

import '../../core/attribute.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/attributes/decoration/decoration_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class BoxDecorationDto extends DecorationDto<BoxDecoration> {
gradient: GradientDto.maybeFrom(decoration.gradient),
boxShadow: decoration.boxShadow?.map(BoxShadowDto.from).toList(),
shape: decoration.shape,
image: DecorationImageDto.maybeFrom(decoration.image),
backgroundBlendMode: decoration.backgroundBlendMode,
image: DecorationImageDto.maybeFrom(decoration.image),
);
}

Expand Down Expand Up @@ -166,13 +166,13 @@ class BoxDecorationDto extends DecorationDto<BoxDecoration> {
BoxDecoration resolve(MixData mix) {
return BoxDecoration(
color: color?.resolve(mix),
image: image?.resolve(mix),
border: border?.resolve(mix),
borderRadius: borderRadius?.resolve(mix),
boxShadow: boxShadow?.map((e) => e.resolve(mix)).toList(),
gradient: gradient?.resolve(mix),
backgroundBlendMode: backgroundBlendMode,
shape: shape ?? BoxShape.rectangle,
image: image?.resolve(mix),
);
}

Expand Down
2 changes: 0 additions & 2 deletions lib/src/attributes/spacing/spacing_dto.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: prefer-moving-to-variable

import 'package:flutter/material.dart';

import '../../factory/mix_provider_data.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/src/attributes/text_style/text_style_dto.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: avoid-non-null-assertion

import 'dart:ui';

import 'package:flutter/material.dart';
Expand Down
7 changes: 7 additions & 0 deletions lib/src/core/extensions/color_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../attributes/color/color_dto.dart';
extension ColorExt on Color {
Color mix(Color toColor, [int amount = 50]) {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;

return Color.fromARGB(
((toColor.alpha - alpha) * p + alpha).round(),
((toColor.red - red) * p + red).round(),
Expand All @@ -19,11 +20,13 @@ extension ColorExt on Color {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;
final hsl = HSLColor.fromColor(this);
final lightness = _clamp(hsl.lightness + p);

return hsl.withLightness(lightness).toColor();
}

Color brighten([int amount = 10]) {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;

return Color.fromARGB(
alpha,
math.max(0, math.min(255, red - (255 * -p).round())),
Expand All @@ -44,6 +47,7 @@ extension ColorExt on Color {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;
final hsl = HSLColor.fromColor(this);
final lightness = _clamp(hsl.lightness - p);

return hsl.withLightness(lightness).toColor();
}

Expand All @@ -61,13 +65,15 @@ extension ColorExt on Color {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;
final hsl = HSLColor.fromColor(this);
final saturation = _clamp(hsl.saturation - p);

return hsl.withSaturation(saturation).toColor();
}

Color saturate([int amount = 10]) {
final p = RangeError.checkValueInInterval(amount, 0, 100, 'amount') / 100;
final hsl = HSLColor.fromColor(this);
final saturation = _clamp(hsl.saturation + p);

return hsl.withSaturation(saturation).toColor();
}

Expand All @@ -76,6 +82,7 @@ extension ColorExt on Color {
Color complement() {
final hsl = HSLColor.fromColor(this);
final hue = (hsl.hue + 180) % 360;

return hsl.withHue(hue).toColor();
}

Expand Down
Loading
Loading