Presets
A preset is a named set of rules, rule parameters and SDK lints. You adopt it whole, with one line:
include: package:assay_lints/strict.yamlassay_lints holds three presets. Each holds all of the one before it, and more, and includes no other file. A preset never changes a rule’s tier: a rule is blocking or advisory wherever it is on.
core |
recommended |
strict |
|
|---|---|---|---|
| assay’s rules | 11 of the 35 blocking rules | 109: all but the 38 that are in strict only |
all 147 |
max_function_length |
— | 60 | 40 |
max_cyclomatic_complexity |
— | 15 | 10 |
max_cognitive_complexity |
— | — | 15 |
max_nesting_depth |
— | 4 | 3 |
max_parameters |
— | 6 | 4 |
max_file_length |
— | 600 | 400 |
max_widget_nesting |
— | 10 | 7 |
| Silent in test directories | — | max_function_length, max_file_length, avoid_late, no_magic_number |
the same four, and nullable_to_string |
| SDK lints switched on | none | 109 | 199 |
| SDK lints raised to blocking | none | the six | the six |
| Strict language modes | no | no | strict-casts, strict-inference, strict-raw-types |
document_ignores |
off | off | off |
| Cross-file checks and asset checks | on | on | on |
- Test directories are
test/**,integration_test/**andtest_driver/**of each package, given to those rules as theirexclude. There a longmainholds every test, a number is the value a test expects, alatevariable is filled by a set-up function, and “null” is the right text for what a test saw. Anexcludeof your own replaces the preset’s list for that rule. - Every other rule parameter keeps the default its rule page gives. The index of rules and checks lists the rules of each preset.
document_ignores, the SDK lint that asks for a comment beside a suppression, is off:suppression_requires_justificationreports the same lack once, with a tier.
The six blocking SDK lints
Section titled “The six blocking SDK lints”empty_catches, unawaited_futures, discarded_futures, avoid_dynamic_calls, use_build_context_synchronously, cancel_subscriptions.
recommended and strict switch them on and raise them to the severity of a warning, which makes them blocking: a report of one fails the gate. Every other SDK lint stays an info and is advisory.
Two of them report a defect that an assay rule of every preset reports too: empty_catches an empty catch block, as avoid_swallowed_errors does, and cancel_subscriptions a subscription never cancelled, as dispose_owned_resources does. Both of each pair stay on, so under recommended and strict one place can be reported twice.
core switches on no SDK lint. The analyzer’s own errors and warnings, such as an unused import, are there under every preset, and they are blocking too.
The SDK lints of recommended (109)
Section titled “The SDK lints of recommended (109)”Show the 109 lints
annotate_overrides, avoid_dynamic_calls, avoid_empty_else, avoid_function_literals_in_foreach_calls, avoid_init_to_null, avoid_print, avoid_relative_lib_imports, avoid_renaming_method_parameters, avoid_return_types_on_setters, avoid_returning_null_for_void, avoid_shadowing_type_parameters, avoid_single_cascade_in_expression_statements, avoid_types_as_parameter_names, avoid_unnecessary_containers, avoid_web_libraries_in_flutter, await_only_futures, camel_case_extensions, camel_case_types, cancel_subscriptions, collection_methods_unrelated_type, constant_identifier_names, control_flow_in_finally, curly_braces_in_flow_control_structures, dangling_library_doc_comments, depend_on_referenced_packages, discarded_futures, empty_catches, empty_constructor_bodies, empty_statements, exhaustive_cases, file_names, hash_and_equals, implementation_imports, implicit_call_tearoffs, invalid_runtime_check_with_js_interop_types, library_annotations, library_prefixes, library_private_types_in_public_api, literal_only_boolean_expressions, no_duplicate_case_values, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, no_logic_in_create_state, no_self_assignments, no_wildcard_variable_uses, non_constant_identifier_names, null_check_on_nullable_type_parameter, null_closures, overridden_fields, package_names, prefer_adjacent_string_concatenation, prefer_collection_literals, prefer_conditional_assignment, prefer_const_constructors_in_immutables, prefer_contains, prefer_final_fields, prefer_for_elements_to_map_fromIterable, prefer_function_declarations_over_variables, prefer_generic_function_type_aliases, prefer_if_null_operators, prefer_initializing_formals, prefer_inlined_adds, prefer_interpolation_to_compose_strings, prefer_is_empty, prefer_is_not_empty, prefer_is_not_operator, prefer_iterable_whereType, prefer_null_aware_operators, prefer_spread_collections, prefer_typing_uninitialized_variables, provide_deprecation_message, recursive_getters, secure_pubspec_urls, sized_box_for_whitespace, slash_for_doc_comments, sort_child_properties_last, strict_top_level_inference, type_init_formals, type_literal_in_constant_pattern, unawaited_futures, unintended_html_in_doc_comment, unnecessary_brace_in_string_interps, unnecessary_const, unnecessary_constructor_name, unnecessary_getters_setters, unnecessary_late, unnecessary_library_name, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_null_in_if_null_operators, unnecessary_nullable_for_final_variable_declarations, unnecessary_overrides, unnecessary_statements, unnecessary_string_escapes, unnecessary_string_interpolations, unnecessary_this, unnecessary_to_list_in_spreads, unnecessary_underscores, unrelated_type_equality_checks, use_build_context_synchronously, use_full_hex_values_for_flutter_colors, use_function_type_syntax_for_parameters, use_key_in_widget_constructors, use_null_aware_elements, use_rethrow_when_possible, use_string_in_part_of_directives, use_super_parameters, valid_regexps, void_checks.
The SDK lints strict adds (90, 199 in all)
Section titled “The SDK lints strict adds (90, 199 in all)”Show the 90 lints
always_declare_return_types, always_put_required_named_parameters_first, always_use_package_imports, avoid_bool_literals_in_conditional_expressions, avoid_catches_without_on_clauses, avoid_catching_errors, avoid_double_and_int_checks, avoid_equals_and_hash_code_on_mutable_classes, avoid_escaping_inner_quotes, avoid_field_initializers_in_const_classes, avoid_final_parameters, avoid_js_rounded_ints, avoid_multiple_declarations_per_line, avoid_positional_boolean_parameters, avoid_redundant_argument_values, avoid_returning_this, avoid_setters_without_getters, avoid_slow_async_io, avoid_type_to_string, avoid_types_on_closure_parameters, avoid_void_async, cascade_invocations, cast_nullable_to_non_nullable, combinators_ordering, comment_references, conditional_uri_does_not_exist, deprecated_consistency, deprecated_member_use_from_same_package, directives_ordering, eol_at_end_of_file, flutter_style_todos, implicit_reopen, invalid_case_patterns, join_return_with_assignment, leading_newlines_in_multiline_strings, matching_super_parameters, missing_code_block_language_in_doc_comment, no_default_cases, no_literal_bool_comparisons, no_runtimeType_toString, noop_primitive_operations, omit_local_variable_types, only_throw_errors, parameter_assignments, prefer_asserts_in_initializer_lists, prefer_asserts_with_message, prefer_const_constructors, prefer_const_declarations, prefer_const_literals_to_create_immutables, prefer_constructors_over_static_methods, prefer_final_in_for_each, prefer_final_locals, prefer_foreach, prefer_if_elements_to_conditional_expressions, prefer_int_literals, prefer_mixin, prefer_null_aware_method_calls, prefer_single_quotes, remove_deprecations_in_breaking_versions, simplify_variable_pattern, sized_box_shrink_expand, sort_constructors_first, sort_pub_dependencies, sort_unnamed_constructors_first, specify_nonobvious_property_types, switch_on_type, test_types_in_equals, throw_in_finally, tighten_type_of_initializing_formals, type_annotate_public_apis, unnecessary_async, unnecessary_breaks, unnecessary_ignore, unnecessary_lambdas, unnecessary_library_directive, unnecessary_null_aware_operator_on_extension_on_nullable, unnecessary_null_checks, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_unawaited, use_colored_box, use_enums, use_is_even_rather_than_modulo, use_named_constants, use_raw_strings, use_setters_to_change_properties, use_string_buffers, use_test_throws_matchers, use_to_and_as_if_applicable, use_truncating_division.
These names are known to Dart 3.11 and 3.13. A name an SDK does not know is a warning in the project’s options file.
Moving from one preset to the next
Section titled “Moving from one preset to the next”Change the one word in the include: line, or run assay init --preset <preset>:
assay init --preset strict╭──────────────────────────────────────────────────────────────────────────────╮│ assay init │╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Files ───────────────────────────────────────────────────────────── 1 file ─╮│ analysis_options.yaml changed ││ + Its `include:` names `package:assay_lints/strict.yaml` in the place of ││ `package:assay_lints/recommended.yaml`: the project adopts the preset ││ strict, and no longer recommended. │╰──────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────╮│ ✓ 1 file changed. │╰──────────────────────────────────────────────────────────────────────────────╯To judge an AI agent's changes at the end of each turn, install the agent pluginof assay: it is separate from this program.If the project has violations under the next preset, adopt it with a baseline: assay baseline update --add records what the project already has, and the gate holds new code to the new preset.
- More rules come from a higher preset. You cannot switch on one rule your preset does not hold:
enabled: truefor it underassay:is a configuration error that names the preset which holds it. - Any rule of your preset can be switched off under
assay:(Configuring rules). - An SDK lint your preset does not name can be switched on under
linter: rules:as always.
At the gate, a change of preset is listed as a configuration change of the key preset, with the rule parameters, severities and language modes the two presets set differently.