spkersten / dart_functional_data

Simple and non-intrusive code generator for lenses and boilerplate of data types
https://pub.dev/packages/functional_data
MIT License
41 stars 15 forks source link

Data generated violates 2 lint errors #16

Closed remonh87 closed 3 years ago

remonh87 commented 4 years ago

When I generate code for the following class

@FunctionalData()
class Bar extends $Bar{
  Bar({this.foo});

  final String foo;
}

It results in:

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'bar.dart';

// **************************************************************************
// FunctionalDataGenerator
// **************************************************************************

// ignore_for_file: join_return_with_assignment
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: avoid_equals_and_hash_code_on_mutable_classes
abstract class $Bar {
  const $Bar();
  String get foo;
  Bar copyWith({String foo}) => Bar(foo: foo ?? this.foo);
  @override
  String toString() => "Bar(foo: $foo)";
  @override
  bool operator ==(dynamic other) =>
      other.runtimeType == runtimeType && foo == other.foo;
  @override
  int get hashCode {
    var result = 17;
    result = 37 * result + foo.hashCode;
    return result;
  }
}

class Bar$ {
  static final foo =
      Lens<Bar, String>((s_) => s_.foo, (s_, foo) => s_.copyWith(foo: foo));
}

This generated code has 2 violations to dart lint.

I will submit a pr that will fix this.

spkersten commented 3 years ago

I'm closing this issue with the rationale given in the linked PR: those lint rules are opinions (there are similar rules for the opposite).

remonh87 commented 3 years ago

yes you are right it would conflict others