facebook pixelDART Static Code Analysis Rules
BACK TO LIST

Dart rules

Codiga provides multiple set of rules for 12+ languages. Below we provide a link and a description for all the rules supported by our platform. Note that not all the rules are being listed and described below.

      ALWAYS_DECLARE_RETURN_TYPES

      Code style
      High

      Method should have return type

      always_specify_types

      Code style
      Minor

      Always specify types

      ARGUMENT_TYPE_NOT_ASSIGNABLE

      Code style
      Medium

      Invalid assignments

      ASSET_DOES_NOT_EXIST

      Code style
      Medium

      Asset does not exists

      AVOID_BOOL_LITERALS_IN_CONDITIONAL_EXPRESSIONS

      Code style
      Minor

      Avoid bool literals in condition

      AVOID_CLASSES_WITH_ONLY_STATIC_MEMBERS

      Code style
      Minor

      Avoid defining a class that contains only static members.

      AVOID_ESCAPING_INNER_QUOTES

      Code style
      Minor

      Avoid escaping inner quotes by converting surrounding quotes.

      AVOID_FUNCTION_LITERALS_IN_FOREACH_CALLS

      Code style
      Minor

      Avoid using `forEach` with a function literal.

      avoid_init_to_null

      Code style
      Minor

      Don't explicitly initialize variables to null.

      AVOID_POSITIONAL_BOOLEAN_PARAMETERS

      Code style
      Minor

      Avoid positional boolean parameters.

      AVOID_PRINT

      Code style
      High

      Avoid `print` calls in production code.

      AVOID_REDUNDANT_ARGUMENT_VALUES

      Code style
      Minor

      Avoid redundant argument values.

      AVOID_RETURN_TYPES_ON_SETTERS

      Code style
      Minor

      Avoid return types on setters.

      AVOID_UNNECESSARY_CONTAINERS

      Code style
      Minor

      Avoid unnecessary containers.

      AVOID_VOID_ASYNC

      Code style
      Minor

      Avoid async functions that return void.

      AVOID_WEB_LIBRARIES_IN_FLUTTER

      Code style
      Minor

      Avoid using web-only libraries outside Flutter web plugin packages.

      AWAIT_ONLY_FUTURES

      Code style
      Minor

      await' should only apply to futures

      BODY_MIGHT_COMPLETE_NORMALLY

      Code style
      Medium

      The body might complete normally

      CAMEL_CASE_TYPES

      Code style
      Minor

      Name types using UpperCamelCase.

      CAST_NULLABLE_TO_NON_NULLABLE

      Code style
      Minor

      Don't cast a nullable value to a non nullable type.

      CAST_TO_NON_TYPE

      Code style
      Medium

      The name isn't a type

      close_sinks

      Code style
      Minor

      Close instances of `dart.core.Sink`.\n

      CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE

      Code style
      Medium

      Const variables must be initialized with a constant value.

      CONST_WITH_NON_CONSTANT_ARGUMENT

      Code style
      Medium

      Arguments of a constant creation must be constant expressions.

      COULD_NOT_INFER

      Code style
      Medium

      Cannot infer type

      CREATION_WITH_NON_TYPE

      Code style
      Medium

      The name 'BubbleStyle' isn't a class.\n

      DEAD_CODE

      Code style
      Minor

      Dead code.

      DEAD_CODE_ON_CATCH_SUBTYPE

      Code style
      Minor

      Dead code on catch subtype.

      DEAD_NULL_AWARE_EXPRESSION

      Code style
      Minor

      The left operand can't be null.

      DEFAULT_LIST_CONSTRUCTOR

      Code style
      Medium

      The default 'List' constructor isn't available when null safety is enabled.

      DEPEND_ON_REFERENCED_PACKAGES

      Code style
      Minor

      Depend on referenced packages.

      DEPRECATED_MEMBER_USE

      Code style
      Minor

      Member is deprecated and shouldn't be used. This property is no longer used

      DIRECTIVES_ORDERING

      Code style
      Minor

      Import ordering

      DUPLICATE_IMPORT

      Code style
      Minor

      Duplicate import.

      EMPTY_CATCHES

      Code style
      Minor

      Avoid empty catch blocks.

      empty_constructor_bodies

      Code style
      Minor

      Use `;` instead of `{}` for empty constructor bodies.

      empty_statements

      Code style
      Minor

      Detect empty statements (dead code)

      EOL_AT_END_OF_FILE

      Code style
      Minor

      Put a single newline at end of file.

      EXPECTED_TOKEN

      Code style
      Medium

      Expected to find '['.

      EXTENDS_NON_CLASS

      Code style
      Medium

      Classes can only extend other classes.

      EXTRA_POSITIONAL_ARGUMENTS

      Code style
      Medium

      Too many positional arguments.

      FILE_NAMES

      Code style
      Minor

      Name source files using `lowercase\_with\_underscores`.

      GETTER_NOT_SUBTYPE_SETTER_TYPES

      Code style
      Medium

      Invalid return type

      HASH_AND_EQUALS

      Code style
      Minor

      Override `hashCode` if overriding `==`

      ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE

      Code style
      High

      Illegal assignment to non-assignable expression.

      implementation_imports

      Code style
      Minor

      Don't import implementation files from another package.

      IMPLEMENTS_NON_CLASS

      Code style
      Medium

      Classes and mixins can only implement other classes and mixins.

      IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE

      Code style
      Minor

      Legacy library

      INCLUDE_FILE_NOT_FOUND

      Code style
      Medium

      Include file not found

      INVALID_ANNOTATION_TARGET

      Code style
      Minor

      Invalid annotation target

      INVALID_ASSIGNMENT

      Code style
      Medium

      Invalid assignments

      INVALID_CONSTANT

      Code style
      Medium

      Invalid constant value

      INVALID_NULL_AWARE_OPERATOR

      Code style
      Minor

      The receiver can't be null because of short-circuiting

      INVALID_OVERRIDE

      Code style
      Medium

      Invalid override

      INVALID_USE_OF_PROTECTED_MEMBER

      Code style
      Minor

      Invalid use of protected members

      INVARIANT_BOOLEANS

      Code style
      Minor

      Conditions should not unconditionally evaluate to `true` or to `false`.

      JOIN_RETURN_WITH_ASSIGNMENT

      Code style
      Minor

      Join return statement with assignment when possible.

      LIBRARY_PREFIXES

      Code style
      Minor

      Use `lowercase\_with\_underscores` when specifying a library prefix.

      LIST_ELEMENT_TYPE_NOT_ASSIGNABLE

      Code style
      Medium

      List element type not assignable

      MISSING_ASSIGNABLE_SELECTOR

      Code style
      High

      Missing selector

      MISSING_DEFAULT_VALUE_FOR_PARAMETER

      Code style
      Medium

      Missing default value for parameter

      MISSING_ENUM_CONSTANT_IN_SWITCH

      Code style
      Minor

      Missing case clause for 'null'.

      MISSING_IDENTIFIER

      Code style
      Medium

      Expected an identifier.

      MISSING_REQUIRED_ARGUMENT

      Code style
      High

      Missing required argument

      MISSING_REQUIRED_PARAM

      Code style
      Medium

      Missing required parameters

      MISSING_RETURN

      Code style
      Minor

      Missing return value

      MIXIN_OF_NON_CLASS

      Code style
      Medium

      Classes can only mix in mixins and classes.

      MIXIN_WITH_NON_CLASS_SUPERCLASS

      Code style
      Medium

      Mixin can only be applied to class.

      MUST_BE_IMMUTABLE

      Code style
      Minor

      Must be immutable

      MUST_CALL_SUPER

      Code style
      Minor

      This method overrides a method annotated as '@mustCallSuper' in 'State'

      NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT

      Code style
      Medium

      The class doesn't have a default constructor.

      NO_DEFAULT_SUPER_CONSTRUCTOR

      Code style
      High

      No default super constructor

      NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER

      Code style
      Medium

      Missing concrete implementations of methods

      NON_BOOL_CONDITION

      Code style
      Medium

      Conditions must have a static type of 'bool'

      NON_CONSTANT_CASE_EXPRESSION

      Code style
      Medium

      Case expressions must be constant

      NON_CONSTANT_DEFAULT_VALUE

      Code style
      Medium

      The default value of an optional parameter must be constant

      non_constant_identifier_names

      Code style
      Minor

      Name non-constant identifiers using lowerCamelCase

      NON_CONSTANT_LIST_ELEMENT

      Code style
      Medium

      The values in a const list literal must be constants

      NON_CONSTANT_MAP_VALUE

      Code style
      Medium

      The values in a const map literal must be constant

      NON_TYPE_AS_TYPE_ARGUMENT

      Code style
      Medium

      The name isn't a type so it can't be used as a type argument

      NON_TYPE_IN_CATCH_CLAUSE

      Code style
      Medium

      The name isn't a type and can't be used in an on-catch clause.

      NOOP_PRIMITIVE_OPERATIONS

      Code style
      Minor

      Noop primitive operations.

      NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE

      Code style
      Medium

      The non-nullable local variable must be assigned before it can be used.

      NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD

      Code style
      Medium

      Non-nullable instance field must be initialized.

      NOT_INITIALIZED_NON_NULLABLE_VARIABLE

      Code style
      Medium

      The non-nullable variable must be initialized.

      NULLABLE_TYPE_IN_CATCH_CLAUSE

      Code style
      Minor

      A potentially nullable type can't be used in an 'on' clause because it isn't valid to throw a nullable expression.

      OVERRIDDEN_FIELDS

      Code style
      Minor

      Don't override fields.

      OVERRIDE_ON_NON_OVERRIDING_MEMBER

      Code style
      Minor

      The field doesn't override an inherited getter or setter.

      POSITIONAL_AFTER_NAMED_ARGUMENT

      Code style
      Medium

      Positional arguments must occur before named arguments.

      PREFER_CONST_CONSTRUCTORS

      Code style
      Minor

      Prefer const with constant constructors.

      PREFER_CONST_CONSTRUCTORS_IN_IMMUTABLES

      Code style
      Minor

      Prefer declaring const constructors on `@immutable` classes

      PREFER_CONST_DECLARATIONS

      Code style
      High

      Prefer const over final for declarations

      PREFER_CONST_LITERALS_TO_CREATE_IMMUTABLES

      Code style
      Minor

      Prefer const literals as parameters of constructors on @immutable classes.

      PREFER_FINAL_IN_FOR_EACH

      Code style
      Minor

      Prefer final in for-each loop variable if reference is not reassigned.

      PREFER_FINAL_LOCALS

      Code style
      High

      Prefer final for variable declarations if they are not reassigned.

      PREFER_IF_ELEMENTS_TO_CONDITIONAL_EXPRESSIONS

      Code style
      Minor

      Prefer if elements to conditional expressions where possible.

      PREFER_IF_NULL_OPERATORS

      Code style
      Minor

      Prefer using if null operators.

      PREFER_INITIALIZING_FORMALS

      Code style
      Minor

      Use initializing formals when possible.

      PREFER_INTERPOLATION_TO_COMPOSE_STRINGS

      Code style
      Minor

      Use interpolation to compose strings and values.

      PREFER_IS_EMPTY

      Code style
      Minor

      Use isEmpty instead of length\n

      PREFER_IS_NOT_EMPTY

      Code style
      Minor

      Use `isNotEmpty` for Iterables and Maps.

      PREFER_NULL_AWARE_METHOD_CALLS

      Code style
      Minor

      Prefer null aware method calls.

      PREFER_TYPING_UNINITIALIZED_VARIABLES

      Code style
      Minor

      Prefer typing uninitialized variables and fields.

      REDIRECT_TO_NON_CLASS

      Code style
      High

      Name isn't a type and can't be used in a redirected constructor.

      REQUIRE_TRAILING_COMMAS

      Code style
      Minor

      Missing a required trailing comma.

      RETURN_OF_INVALID_TYPE

      Code style
      Medium

      Invalid return type

      RETURN_OF_INVALID_TYPE_FROM_CLOSURE

      Code style
      Medium

      Invalid return type from closure

      SIZED_BOX_FOR_WHITESPACE

      Code style
      Minor

      SizedBox for whitespace.

      SORT_CHILD_PROPERTIES_LAST

      Code style
      High

      Sort child properties last in widget instance creations.

      SORT_PUB_DEPENDENCIES

      Code style
      Minor

      Sort pub dependencies.

      TYPE_ANNOTATE_PUBLIC_APIS

      Code style
      High

      Type annotate public APIs.

      TYPE_ARGUMENT_NOT_MATCHING_BOUNDS

      Code style
      High

      Type arguments do not match bounds

      TYPE_TEST_WITH_UNDEFINED_NAME

      Code style
      Medium

      Undefined name

      UNCHECKED_USE_OF_NULLABLE_VALUE

      Code style
      Medium

      Method can't be unconditionally invoked because the receiver can be 'null'.

      UNDEFINED_CONSTRUCTOR_IN_INITIALIZER

      Code style
      Medium

      Undefined constructor

      UNDEFINED_GETTER

      Code style
      Medium

      Undefined getter

      UNDEFINED_NAMED_PARAMETER

      Code style
      Medium

      Named parameter undefined

      UNDEFINED_OPERATOR

      Code style
      High

      Undefined operator

      UNDEFINED_SETTER

      Code style
      Medium

      Undefined setter

      UNDEFINED_SUPER_MEMBER

      Code style
      Medium

      Undefined super member

      unnecessary_brace_in_string_interps

      Code style
      Minor

      Avoid using braces in interpolation when not needed.

      UNNECESSARY_CAST

      Code style
      Minor

      Unnecessary cast.

      UNNECESSARY_NEW

      Code style
      Minor

      Unnecessary new keyword.

      UNNECESSARY_NON_NULL_ASSERTION

      Code style
      Medium

      Uneccessary non null assertion

      UNNECESSARY_NULL_CHECKS

      Code style
      Minor

      Unnecessary null checks

      UNNECESSARY_NULL_COMPARISON

      Code style
      Minor

      The operand can't be null

      UNNECESSARY_PARENTHESIS

      Code style
      Minor

      Unnecessary parenthesis

      unnecessary_statements

      Code style
      Minor

      Avoid using unnecessary statements

      UNNECESSARY_STRING_INTERPOLATIONS

      Code style
      Minor

      Unnecessary string interpolation

      UNNECESSARY_THIS

      Code style
      High

      Unecessary this

      UNSUPPORTED_OPERATOR

      Code style
      High

      The '===' operator is not supported

      UNUSED_CATCH_CLAUSE

      Code style
      Minor

      Unused catch clause

      UNUSED_CATCH_STACK

      Code style
      Minor

      Stack trace not used

      UNUSED_ELEMENT

      Code style
      Minor

      Unused element

      UNUSED_FIELD

      Code style
      Minor

      Unused fiel

      UNUSED_IMPORT

      Code style
      Minor

      Unused import

      UNUSED_LABEL

      Code style
      Minor

      Unused label

      UNUSED_LOCAL_VARIABLE

      Code style
      Minor

      Unused local variable

      URI_HAS_NOT_BEEN_GENERATED

      Code style
      Medium

      URI has not been generated

      USE_BUILD_CONTEXT_SYNCHRONOUSLY

      Code style
      Minor

      Use build context synchronuously

      USE_LATE_FOR_PRIVATE_FIELDS_AND_VARIABLES

      Code style
      Minor

      Use late for private members with non-nullable type.

      USE_NAMED_CONSTANTS

      Code style
      Minor

      Use named constants

      USE_OF_VOID_RESULT

      Code style
      High

      Use of void results

      USE_STRING_BUFFERS

      Code style
      Minor

      Use string buffers to compose strings

      ALWAYS_USE_PACKAGE_IMPORTS

      Best practice
      High

      Avoid relative imports.

      Learn more

      ANNOTATE_OVERRIDES

      Best practice
      Medium

      Annotate overridden members.

      AVOID_DYNAMIC_CALLS

      Best practice
      High

      Avoid method calls or property accesses on a "dynamic" target

      https://dart-lang.github.io/linter/lints/avoid_returning_null_for_void.html

      Best practice
      Critical

      Avoid returning null for void

      AVOID_RETURNING_NULL_FOR_VOID

      Safety
      High

      Avoid returning null for void

      CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH

      Error prone
      Medium

      Type mismatch in constructor parameter

      CONST_EVAL_THROWS_EXCEPTION

      Best practice
      High

      Eval throws exception.

      LEADING_NEWLINES_IN_MULTILINE_STRINGS

      Best practice
      Medium

      Start multiline strings with a newline.

      UNNECESSARY_IMPORT

      Best practice
      Minor

      Unnecessary import

      NOT_ENOUGH_POSITIONAL_ARGUMENTS

      Error prone
      High

      Incorrect number of arguments passed to function call

      UNNECESSARY_TYPE_CHECK

      Best practice
      Medium

      Unnecessary type check

      BODY_MIGHT_COMPLETE_NORMALLY_NULLABLE

      Best practice
      Medium

      The analyzer produces this diagnostic when a method or function can implicitly return null by falling off the end. While this is valid Dart code, it’s better for the return of null to be explicit.

      UNNECESSARY_DEV_DEPENDENCY

      Error prone
      Medium

      The dev dependency is unnecessary because there is also a normal dependency on that package.

      NULL_ARGUMENT_TO_NON_NULL_TYPE

      Safety
      High

      Function/method shouldn’t be called with a null argument for the non-nullable type argument.

      UNNECESSARY_QUESTION_MARK

      Best practice
      Medium

      The ‘?’ is unnecessary because the value is nullable without it.

      DUPLICATE_NAMED_ARGUMENT

      Error prone
      High

      The argument was already specified.

      NO_LEADING_UNDERSCORES_FOR_LOCAL_IDENTIFIERS

      Code style
      Medium

      Avoid leading underscores for local identifiers.

      PREFER_FINAL_FIELDS

      Best practice
      Medium

      Field could be final.

      PREFER_GENERIC_FUNCTION_TYPE_ALIASES

      Best practice
      Medium

      Prefer generic function type aliases.

      VARIABLE_TYPE_MISMATCH

      Error prone
      Critical

      Type mismatch in assignment

      AVOID_IMPLEMENTING_VALUE_TYPES

      Best practice
      Medium

      Don't implement classes that override `==`.

      AVOID_SETTERS_WITHOUT_GETTERS

      Design
      Medium

      Avoid setters without getters.

      CONSTANT_IDENTIFIER_NAMES

      Code style
      Medium

      Prefer using lowerCamelCase for constant names.

      UNNECESSARY_OVERRIDES

      Best practice
      Medium

      Don't override a method to do a super method invocation with the same parameters.

      DUPLICATE_DEFINITION

      Error prone
      Medium

      Name already defined.

      DIRECTIVE_AFTER_DECLARATION

      Code style
      Minor

      Directives must appear before any declarations.

      DUPLICATE_PART

      Best practice
      Medium

      The library already contains a part.

      EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED

      Error prone
      Medium

      Too many positional arguments.

      FLUTTER_STYLE_TODOS

      Code style
      Minor

      Use Flutter TODO format.

      NO_LEADING_UNDERSCORES_FOR_LIBRARY_PREFIXES

      Code style
      Minor

      Avoid leading underscores for library prefixes.

      INVALID_FACTORY_NAME_NOT_A_CLASS

      Code style
      Minor

      The name of a factory constructor must be the same as the name of the immediately enclosing class.

      INVALID_LANGUAGE_VERSION_OVERRIDE

      Best practice
      Medium

      The language version override must be specified before any declaration or directive.

      INSTANCE_ACCESS_TO_STATIC_MEMBER

      Error prone
      High

      Static method can't be accessed through an instance.

      INVALID_RETURN_TYPE_FOR_CATCH_ERROR

      Design
      High

      Invalid return type value

      LIBRARY_PRIVATE_TYPES_IN_PUBLIC_API

      Design
      High

      Using library private types in public APIs

      UNRELATED_TYPE_EQUALITY_CHECKS

      Error prone
      High

      Equality operator `==` invocation with references of unrelated types

      USE_KEY_IN_WIDGET_CONSTRUCTORS

      Best practice
      High

      Use key in widget constructors.