Skip to content

Commit

Permalink
Fix generated ignore_for_file directives (#833)
Browse files Browse the repository at this point in the history
- Bring unnecessary_import back. (was removed with #778)

- Generate unused_import in grpc files as well.

- Don't generate return_of_invalid_type: this lint seems to be removed.

(The first two issues were found in cl/535141580)
  • Loading branch information
osa1 authored May 30, 2023
1 parent 35ea45f commit 346a72d
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 55 deletions.
5 changes: 3 additions & 2 deletions protoc_plugin/lib/src/file_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class FileGenerator extends ProtobufContainer {
/// Writes the header and imports for the .pb.dart file.
void writeMainHeader(IndentingWriter out,
[OutputConfiguration config = const DefaultOutputConfiguration()]) {
_writeHeading(out, extraIgnores: {'unnecessary_import'});
_writeHeading(out);

final importWriter = ImportWriter();

Expand Down Expand Up @@ -710,6 +710,7 @@ const _fileIgnores = {
'library_prefixes',
'non_constant_identifier_names',
'prefer_final_fields',
'return_of_invalid_type',
'unnecessary_import',
'unnecessary_this',
'unused_import',
};
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/grpc_service.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/grpc_service.pbgrpc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;
Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/header_in_package.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/header_with_fixnum.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/imports.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/imports.pbjson
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/int64.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/oneMessage.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
56 changes: 28 additions & 28 deletions protoc_plugin/test/goldens/oneMessage.pb.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2,121 +2,121 @@ annotation: {
path: 4
path: 0
sourceFile: test
begin: 434
end: 445
begin: 425
end: 436
}
annotation: {
path: 4
path: 0
sourceFile: test
begin: 516
end: 527
begin: 507
end: 518
}
annotation: {
path: 4
path: 0
path: 2
path: 0
sourceFile: test
begin: 2236
end: 2242
begin: 2227
end: 2233
}
annotation: {
path: 4
path: 0
path: 2
path: 0
sourceFile: test
begin: 2284
end: 2290
begin: 2275
end: 2281
}
annotation: {
path: 4
path: 0
path: 2
path: 0
sourceFile: test
begin: 2363
end: 2372
begin: 2354
end: 2363
}
annotation: {
path: 4
path: 0
path: 2
path: 0
sourceFile: test
begin: 2415
end: 2426
begin: 2406
end: 2417
}
annotation: {
path: 4
path: 0
path: 2
path: 1
sourceFile: test
begin: 2484
end: 2488
begin: 2475
end: 2479
}
annotation: {
path: 4
path: 0
path: 2
path: 1
sourceFile: test
begin: 2530
end: 2534
begin: 2521
end: 2525
}
annotation: {
path: 4
path: 0
path: 2
path: 1
sourceFile: test
begin: 2609
end: 2616
begin: 2600
end: 2607
}
annotation: {
path: 4
path: 0
path: 2
path: 1
sourceFile: test
begin: 2659
end: 2668
begin: 2650
end: 2659
}
annotation: {
path: 4
path: 0
path: 2
path: 2
sourceFile: test
begin: 2729
end: 2733
begin: 2720
end: 2724
}
annotation: {
path: 4
path: 0
path: 2
path: 2
sourceFile: test
begin: 2780
end: 2784
begin: 2771
end: 2775
}
annotation: {
path: 4
path: 0
path: 2
path: 2
sourceFile: test
begin: 2857
end: 2864
begin: 2848
end: 2855
}
annotation: {
path: 4
path: 0
path: 2
path: 2
sourceFile: test
begin: 2907
end: 2916
begin: 2898
end: 2907
}
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/oneMessage.pbjson
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:convert' as $convert;
import 'dart:core' as $core;
Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/service.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;
Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/service.pbserver
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ignore_for_file: constant_identifier_names
// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;
Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/serviceGenerator.pb.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:convert' as $convert;
import 'dart:core' as $core;
Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/topLevelEnum.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_import, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/topLevelEnum.pbenum
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:core' as $core;

Expand Down
20 changes: 10 additions & 10 deletions protoc_plugin/test/goldens/topLevelEnum.pbenum.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@ annotation: {
path: 5
path: 0
sourceFile: test
begin: 414
end: 423
begin: 425
end: 434
}
annotation: {
path: 5
path: 0
path: 2
path: 0
sourceFile: test
begin: 476
end: 482
begin: 487
end: 493
}
annotation: {
path: 5
path: 0
path: 2
path: 1
sourceFile: test
begin: 558
end: 562
begin: 569
end: 573
}
annotation: {
path: 5
path: 0
path: 2
path: 2
sourceFile: test
begin: 636
end: 640
begin: 647
end: 651
}
annotation: {
path: 5
path: 0
path: 2
path: 3
sourceFile: test
begin: 715
end: 723
begin: 726
end: 734
}
2 changes: 1 addition & 1 deletion protoc_plugin/test/goldens/topLevelEnum.pbjson
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ignore_for_file: annotate_overrides, camel_case_types
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: return_of_invalid_type, unnecessary_this
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:convert' as $convert;
import 'dart:core' as $core;
Expand Down

0 comments on commit 346a72d

Please sign in to comment.