Skip to content

Commit

Permalink
Create cocoon analysis_options.yaml (flutter#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Hillers authored Aug 26, 2022
1 parent a95207a commit 7f0c568
Show file tree
Hide file tree
Showing 46 changed files with 189 additions and 327 deletions.
44 changes: 44 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Specify analysis options for all of flutter/cocoon
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: false
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
implicit_dynamic_parameter: info
exclude:
- ".dart_tool/**"
- "**/*.g.dart"
- "**/*.pb.dart"
- "**/*.pbjson.dart"
- "**/*.pbenum.dart"
- "test/**/mocks.mocks.dart"

linter:
rules:
use_super_parameters: true
48 changes: 2 additions & 46 deletions app_dart/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
# Specify analysis options.
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
sdk_version_async_exported_from_core: ignore
implicit_dynamic_parameter: info
exclude:
- ".dart_tool/**"
- "**/*.g.dart"
- "**/*.pb.dart"
- "**/*.pbjson.dart"
- "**/*.pbenum.dart"
- "test/src/utilities/mocks.mocks.dart"

include: package:flutter_lints/flutter.yaml
include: ../analysis_options.yaml

linter:
rules:
# a few rules listed below are the ones we would like to exclude from flutter_lint package, for app_dart
# reasons for exclusions are provided in the comments to the right
avoid_print: false # we have necessary print calls in the code
constant_identifier_names: false # we have all capitalized enums in check_for_waiting_pull_requests_test.dart
constant_identifier_names: false # we have all capitalized enums in check_for_waiting_pull_requests_test.dart
2 changes: 1 addition & 1 deletion app_dart/lib/src/model/ci_yaml/ci_yaml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DependencyValidator {
final List<String> exceptions = <String>[];

/// Decoded will contain a list of maps for the dependencies found.
dynamic decoded = json.decode(dependencyJsonString);
List<dynamic> decoded = json.decode(dependencyJsonString) as List<dynamic>;

for (Map<String, dynamic> depMap in decoded) {
if (!depMap.containsKey('version')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BatchBackfiller extends RequestHandler {

@override
Future<Body> get() async {
final List<Future> futures = <Future>[];
final List<Future<void>> futures = <Future<void>>[];

for (RepositorySlug slug in config.supportedRepos) {
futures.add(backfillRepository(slug));
Expand Down Expand Up @@ -81,7 +81,7 @@ class BatchBackfiller extends RequestHandler {
log.fine(backfill.map<String>((Tuple<Target, FullTask, int> tuple) => tuple.first.value.name));

// Create list of backfill requests.
final List<Future> futures = <Future>[];
final List<Future<void>> futures = <Future<void>>[];
for (Tuple<Target, FullTask, int> tuple in backfill) {
// TODO(chillers): The backfill priority is always going to be low. If this is a ToT task, we should run it at the default priority.
final Tuple<Target, Task, int> toBeScheduled = Tuple(
Expand Down
2 changes: 1 addition & 1 deletion app_dart/lib/src/request_handling/api_request_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ abstract class ApiRequestHandler<T extends Body> extends RequestHandler<T> {
}

class ApiKey<T> extends RequestKey<T> {
const ApiKey._(String name) : super(name);
const ApiKey._(super.name);

static const ApiKey<Uint8List> requestBody = ApiKey<Uint8List>._('requestBody');
static const ApiKey<AuthenticatedContext> authContext = ApiKey<AuthenticatedContext>._('authenticatedContext');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ abstract class NoAuthRequestHandler<T extends Body> extends RequestHandler<T> {

@visibleForTesting
class NoAuthKey<T> extends RequestKey<T> {
const NoAuthKey._(String name) : super(name);
const NoAuthKey._(super.name);

static const NoAuthKey<Uint8List> requestBody = NoAuthKey<Uint8List>._('requestBody');
static const NoAuthKey<Map<String, dynamic>> requestData = NoAuthKey<Map<String, dynamic>>._('requestData');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ abstract class SubscriptionHandler extends RequestHandler<Body> {

@visibleForTesting
class PubSubKey<T> extends RequestKey<T> {
const PubSubKey._(String name) : super(name);
const PubSubKey._(super.name);

static const PubSubKey<PushMessage> message = PubSubKey<PushMessage>._('message');
}
2 changes: 1 addition & 1 deletion app_dart/lib/src/service/scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Scheduler {
///
/// Each batch request contains [Config.batchSize] builds to be scheduled.
Future<void> _batchScheduleBuilds(Commit commit, List<Tuple<Target, Task, int>> toBeScheduled) async {
final List<Future> futures = <Future>[];
final List<Future<void>> futures = <Future<void>>[];
for (int i = 0; i < toBeScheduled.length; i += config.batchSize) {
futures.add(luciBuildService.schedulePostsubmitBuilds(
commit: commit,
Expand Down
51 changes: 4 additions & 47 deletions auto_submit/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
# Specify analysis options.
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
include: ../analysis_options.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
sdk_version_async_exported_from_core: ignore
implicit_dynamic_parameter: info
exclude:
- ".dart_tool/**"
- "**/*.g.dart"
- "**/*.pb.dart"
- "**/*.pbjson.dart"
- "**/*.pbenum.dart"
- "test/src/utilities/mocks.mocks.dart"

include: package:flutter_lints/flutter.yaml
language:
strict-raw-types: false # TODO: Remove this lint

linter:
rules:
# a few rules listed below are the ones we would like to exclude from flutter_lint package, for app_dart
# reasons for exclusions are provided in the comments to the right
avoid_print: false # we have necessary print calls in the code
constant_identifier_names: false # we have all capitalized enums in check_for_waiting_pull_requests_test.dart
constant_identifier_names: false # we have all capitalized enums in check_for_waiting_pull_requests_test.dart
8 changes: 3 additions & 5 deletions auto_submit/lib/requests/check_pull_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import 'package:googleapis/pubsub/v1.dart' as pub;
import 'package:shelf/shelf.dart';
import '../service/validation_service.dart';

import '../request_handling/authentication.dart';
import '../request_handling/pubsub.dart';
import '../service/config.dart';

import '../service/log.dart';
import '../server/authenticated_request_handler.dart';
Expand All @@ -24,11 +22,11 @@ import '../server/authenticated_request_handler.dart';
/// check if the pull request is mergable.
class CheckPullRequest extends AuthenticatedRequestHandler {
const CheckPullRequest({
required Config config,
required CronAuthProvider cronAuthProvider,
required super.config,
required super.cronAuthProvider,
this.approverProvider = ApproverService.defaultProvider,
this.pubsub = const PubSub(),
}) : super(config: config, cronAuthProvider: cronAuthProvider);
});

final PubSub pubsub;
final ApproverServiceProvider approverProvider;
Expand Down
4 changes: 2 additions & 2 deletions auto_submit/lib/requests/github_webhook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import '../requests/exceptions.dart';
/// check if the pull request is mergable and publish to pubsub.
class GithubWebhook extends RequestHandler {
const GithubWebhook({
required Config config,
required super.config,
this.pubsub = const PubSub(),
}) : super(config: config);
});

final PubSub pubsub;

Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/requests/readiness_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import 'dart:async';

import 'package:shelf/shelf.dart';

import '../service/config.dart';
import '../server/request_handler.dart';

/// Handler for readiness checks.
class ReadinessCheck extends RequestHandler {
const ReadinessCheck({
required Config config,
}) : super(config: config);
required super.config,
});

@override
Future<Response> get() async {
Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/server/authenticated_request_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:shelf/shelf.dart';

import 'request_handler.dart';
import '../request_handling/authentication.dart';
import '../service/config.dart';
import '../requests/exceptions.dart';
import '../service/log.dart';

Expand All @@ -18,9 +17,9 @@ import '../service/log.dart';
abstract class AuthenticatedRequestHandler extends RequestHandler {
/// Creates a new [ApiRequestHandler].
const AuthenticatedRequestHandler({
required Config config,
required super.config,
required this.cronAuthProvider,
}) : super(config: config);
});

/// Service responsible for authenticating this [Request].
final CronAuthProvider cronAuthProvider;
Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/validations/approval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import 'package:auto_submit/model/auto_submit_query_result.dart';
import 'package:auto_submit/validations/validation.dart';
import 'package:github/github.dart' as github;

import '../service/config.dart';
import '../service/log.dart';

/// Validates that a PR has been approved in accordance with the code review
/// guidelines.
class Approval extends Validation {
Approval({
required Config config,
}) : super(config: config);
required super.config,
});

@override

Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/validations/change_requested.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import 'package:auto_submit/model/auto_submit_query_result.dart';
import 'package:auto_submit/validations/validation.dart';
import 'package:github/github.dart' as github;

import '../service/config.dart';
import '../service/log.dart';

/// Validates the PR does not have any pending change requests.
class ChangeRequested extends Validation {
ChangeRequested({
required Config config,
}) : super(config: config);
required super.config,
});

@override

Expand Down
4 changes: 2 additions & 2 deletions auto_submit/lib/validations/ci_successful.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class CiSuccessful extends Validation {
};

CiSuccessful({
required Config config,
}) : super(config: config);
required super.config,
});

@override

Expand Down
6 changes: 2 additions & 4 deletions auto_submit/lib/validations/conflicting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import 'package:auto_submit/model/auto_submit_query_result.dart';
import 'package:auto_submit/validations/validation.dart';
import 'package:github/github.dart' as github;

import '../service/config.dart';

/// Validates the PR is not conflicting.
class Conflicting extends Validation {
Conflicting({
required Config config,
}) : super(config: config);
required super.config,
});

@override

Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/validations/empty_checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import 'package:auto_submit/model/auto_submit_query_result.dart';
import 'package:auto_submit/validations/validation.dart';
import 'package:github/github.dart' as github;

import '../service/config.dart';
import '../service/github_service.dart';

/// Validates that the list of checks for the PR is not empty.
class EmptyChecks extends Validation {
EmptyChecks({
required Config config,
}) : super(config: config);
required super.config,
});

@override

Expand Down
5 changes: 2 additions & 3 deletions auto_submit/lib/validations/revert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import 'package:auto_submit/service/github_service.dart';
import 'package:auto_submit/validations/validation.dart';
import 'package:github/github.dart' as github;

import '../service/config.dart';
import '../service/log.dart';

class Revert extends Validation {
Revert({
required Config config,
}) : super(config: config);
required super.config,
});

static const Set<String> allowedReviewers = <String>{ORG_MEMBER, ORG_OWNER};

Expand Down
Loading

0 comments on commit 7f0c568

Please sign in to comment.