@sun-asterisk/sunlint 1.3.39 → 1.3.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/rules/rules-registry-generated.json +134 -108
- package/docs/GENERATED_FILES_QUICK_REFERENCE.md +96 -0
- package/docs/GENERATED_FILE_HANDLING_SUMMARY.md +152 -0
- package/docs/skills/CREATE_NEW_DART_RULE.md +161 -14
- package/origin-rules/dart-en.md +151 -163
- package/package.json +2 -1
- package/rules/dart/D002_dispose_resources/config.json +25 -0
- package/rules/dart/D003_prefer_widgets_over_methods/config.json +14 -0
- package/rules/dart/D004_avoid_shrinkwrap_listview/config.json +13 -0
- package/rules/dart/D005_limit_widget_nesting/config.json +13 -0
- package/rules/dart/D006_prefer_extracting_large_callbacks/config.json +25 -0
- package/rules/dart/D007_prefer_init_first_dispose_last/config.json +10 -0
- package/rules/dart/D008_avoid_long_functions/config.json +12 -0
- package/rules/dart/D009_limit_function_parameters/config.json +13 -0
- package/rules/dart/D010_limit_cyclomatic_complexity/config.json +12 -0
- package/rules/dart/D011_prefer_named_parameters/config.json +12 -0
- package/rules/dart/D012_prefer_named_boolean_parameters/config.json +9 -0
- package/rules/dart/D013_single_public_class/config.json +10 -0
- package/rules/dart/D014_unsafe_collection_access/config.json +10 -0
- package/rules/dart/D015_copywith_all_parameters/config.json +9 -0
- package/rules/dart/D016_project_should_have_tests/config.json +24 -0
- package/rules/dart/D017_pubspec_dependencies_review/config.json +23 -0
- package/rules/dart/D018_remove_commented_code/config.json +13 -0
- package/rules/dart/D019_avoid_single_child_multi_child_widget/config.json +21 -0
- package/rules/dart/D020_limit_if_else_branches/config.json +12 -0
- package/rules/dart/D021_avoid_negated_boolean_checks/config.json +14 -0
- package/rules/dart/D022_use_setstate_correctly/config.json +14 -0
- package/rules/dart/D023_avoid_unnecessary_method_overrides/config.json +13 -0
- package/rules/dart/D024_avoid_unnecessary_stateful_widget/config.json +9 -0
- package/rules/dart/D025_avoid_nested_conditional_expressions/config.json +9 -0
- package/skill-assets/sunlint-code-quality/AGENTS.md +80 -0
- package/skill-assets/sunlint-code-quality/SKILL.md +176 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C006-verb-noun-functions.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C013-no-dead-code.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C014-dependency-injection.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C017-no-constructor-logic.md +46 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C018-generic-errors.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C019-error-log-level.md +29 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C020-no-unused-imports.md +30 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C022-no-unused-variables.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C023-no-duplicate-names.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C024-centralize-constants.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C029-catch-log-root-cause.md +40 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C030-custom-error-classes.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C033-separate-data-access.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C035-error-context-logging.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C041-no-hardcoded-secrets.md +25 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C042-boolean-naming.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C052-controller-parsing.md +41 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C060-superclass-logic.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/C067-no-hardcoded-config.md +24 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S003-open-redirect.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S004-no-log-credentials.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S005-server-authorization.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S006-default-credentials.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S007-output-encoding.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S009-approved-crypto.md +37 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S010-csprng.md +32 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S011-encrypted-client-hello.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S012-secrets-management.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S013-tls-connections.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S016-no-sensitive-query-string.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S017-parameterized-queries.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S019-email-input-sanitization.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S020-eval-code-execution.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S022-context-escaping.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S023-dynamic-js-encoding.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S025-server-validation.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S026-tls-encryption.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S027-mtls-validation.md +40 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S028-upload-limits.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S029-csrf-protection.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S030-directory-browsing.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S031-secure-cookie-flag.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S032-httponly-cookie.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S033-samesite-cookie.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S034-host-prefix-cookie.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S035-app-hostnames.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S036-internal-file-paths.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S037-anti-cache-headers.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S039-tls-certificate-validation.md +41 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S041-logout-invalidation.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S042-long-lived-sessions.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S044-critical-changes-reauth.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S045-brute-force-protection.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S047-oauth-csrf-protection.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S048-oauth-redirect-validation.md +37 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S049-auth-code-expiry.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S050-token-entropy.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S051-password-length.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S052-otp-entropy.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S053-generic-error-messages.md +32 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S054-no-default-admin.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S055-content-type-validation.md +44 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S056-log-injection.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S057-synchronized-time.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/csharp/S058-ssrf-protection.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/java/C006-verb-noun-functions.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/C013-no-dead-code.md +175 -0
- package/skill-assets/sunlint-code-quality/rules/java/C014-dependency-injection.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/java/C017-no-constructor-logic.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/java/C018-generic-errors.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/java/C019-error-log-level.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/java/C020-no-unused-imports.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/java/C022-no-unused-variables.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/java/C023-no-duplicate-names.md +37 -0
- package/skill-assets/sunlint-code-quality/rules/java/C024-centralize-constants.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/C029-catch-log-root-cause.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/java/C030-custom-error-classes.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/java/C033-separate-data-access.md +46 -0
- package/skill-assets/sunlint-code-quality/rules/java/C035-error-context-logging.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/C041-no-hardcoded-secrets.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/java/C042-boolean-naming.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/java/C052-controller-parsing.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/java/C060-superclass-logic.md +32 -0
- package/skill-assets/sunlint-code-quality/rules/java/C067-no-hardcoded-config.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/java/S003-open-redirect.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/S004-no-log-credentials.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/S005-server-authorization.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/java/S006-default-credentials.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/java/S007-output-encoding.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/java/S009-approved-crypto.md +40 -0
- package/skill-assets/sunlint-code-quality/rules/java/S010-csprng.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/S011-encrypted-client-hello.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/java/S012-secrets-management.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/java/S013-tls-connections.md +40 -0
- package/skill-assets/sunlint-code-quality/rules/java/S016-no-sensitive-query-string.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/S017-parameterized-queries.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/java/S019-email-input-sanitization.md +32 -0
- package/skill-assets/sunlint-code-quality/rules/java/S020-eval-code-execution.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/java/S022-context-escaping.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/java/S023-dynamic-js-encoding.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/java/S025-server-validation.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/java/S026-tls-encryption.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/java/S027-mtls-validation.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/java/S028-upload-limits.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/java/S029-csrf-protection.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/java/S030-directory-browsing.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/S031-secure-cookie-flag.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/S032-httponly-cookie.md +31 -0
- package/skill-assets/sunlint-code-quality/rules/java/S033-samesite-cookie.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/java/S034-host-prefix-cookie.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/java/S035-app-hostnames.md +23 -0
- package/skill-assets/sunlint-code-quality/rules/java/S036-internal-file-paths.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/java/S037-anti-cache-headers.md +37 -0
- package/skill-assets/sunlint-code-quality/rules/java/S039-tls-certificate-validation.md +43 -0
- package/skill-assets/sunlint-code-quality/rules/java/S041-logout-invalidation.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/java/S042-long-lived-sessions.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/S044-critical-changes-reauth.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/java/S045-brute-force-protection.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/S047-oauth-csrf-protection.md +33 -0
- package/skill-assets/sunlint-code-quality/rules/java/S048-oauth-redirect-validation.md +25 -0
- package/skill-assets/sunlint-code-quality/rules/java/S049-auth-code-expiry.md +23 -0
- package/skill-assets/sunlint-code-quality/rules/java/S050-token-entropy.md +20 -0
- package/skill-assets/sunlint-code-quality/rules/java/S051-password-length.md +20 -0
- package/skill-assets/sunlint-code-quality/rules/java/S052-otp-entropy.md +23 -0
- package/skill-assets/sunlint-code-quality/rules/java/S053-generic-error-messages.md +21 -0
- package/skill-assets/sunlint-code-quality/rules/java/S054-no-default-admin.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/java/S055-content-type-validation.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/java/S056-log-injection.md +38 -0
- package/skill-assets/sunlint-code-quality/rules/java/S057-synchronized-time.md +35 -0
- package/skill-assets/sunlint-code-quality/rules/java/S058-ssrf-protection.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C006-verb-noun-functions.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C013-no-dead-code.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C014-dependency-injection.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C017-no-constructor-logic.md +68 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C018-generic-errors.md +46 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C019-error-log-level.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C020-no-unused-imports.md +44 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C022-no-unused-variables.md +39 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C023-no-duplicate-names.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C024-centralize-constants.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C029-catch-log-root-cause.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C030-custom-error-classes.md +72 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C033-separate-data-access.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C035-error-context-logging.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C041-no-hardcoded-secrets.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C042-boolean-naming.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C052-controller-parsing.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C060-superclass-logic.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/C067-no-hardcoded-config.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S003-open-redirect.md +66 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S004-no-log-credentials.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S005-server-authorization.md +75 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S006-default-credentials.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S007-output-encoding.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S009-approved-crypto.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S010-csprng.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S011-encrypted-client-hello.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S012-secrets-management.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S013-tls-connections.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S016-no-sensitive-query-string.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S017-parameterized-queries.md +41 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S019-email-input-sanitization.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S020-eval-code-execution.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S022-context-escaping.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S023-dynamic-js-encoding.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S025-server-validation.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S026-tls-encryption.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S027-mtls-validation.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S028-upload-limits.md +67 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S029-csrf-protection.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S030-directory-browsing.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S031-secure-cookie-flag.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S032-httponly-cookie.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S033-samesite-cookie.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S034-host-prefix-cookie.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S035-app-hostnames.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S036-internal-file-paths.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S037-anti-cache-headers.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S039-tls-certificate-validation.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S041-logout-invalidation.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S042-long-lived-sessions.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S044-critical-changes-reauth.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S045-brute-force-protection.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S047-oauth-csrf-protection.md +74 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S048-oauth-redirect-validation.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S049-auth-code-expiry.md +70 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S050-token-entropy.md +65 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S051-password-length.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S052-otp-entropy.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S053-generic-error-messages.md +66 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S054-no-default-admin.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S055-content-type-validation.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S056-log-injection.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S057-synchronized-time.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/kotlin/S058-ssrf-protection.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/php/C006-verb-noun-functions.md +46 -0
- package/skill-assets/sunlint-code-quality/rules/php/C013-no-dead-code.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/php/C014-dependency-injection.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/php/C017-no-constructor-logic.md +68 -0
- package/skill-assets/sunlint-code-quality/rules/php/C018-generic-errors.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/php/C019-error-log-level.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/C020-no-unused-imports.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/php/C022-no-unused-variables.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/php/C023-no-duplicate-names.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/php/C024-centralize-constants.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/php/C029-catch-log-root-cause.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/php/C030-custom-error-classes.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/php/C033-separate-data-access.md +79 -0
- package/skill-assets/sunlint-code-quality/rules/php/C035-error-context-logging.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/C041-no-hardcoded-secrets.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/php/C042-boolean-naming.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/php/C052-controller-parsing.md +66 -0
- package/skill-assets/sunlint-code-quality/rules/php/C060-superclass-logic.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/C067-no-hardcoded-config.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/php/S003-open-redirect.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/php/S004-no-log-credentials.md +67 -0
- package/skill-assets/sunlint-code-quality/rules/php/S005-server-authorization.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/php/S006-default-credentials.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/php/S007-output-encoding.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/php/S009-approved-crypto.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/php/S010-csprng.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/php/S011-encrypted-client-hello.md +41 -0
- package/skill-assets/sunlint-code-quality/rules/php/S012-secrets-management.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/php/S013-tls-connections.md +67 -0
- package/skill-assets/sunlint-code-quality/rules/php/S016-no-sensitive-query-string.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/php/S017-parameterized-queries.md +44 -0
- package/skill-assets/sunlint-code-quality/rules/php/S019-email-input-sanitization.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/S020-eval-code-execution.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/php/S022-context-escaping.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/php/S023-dynamic-js-encoding.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/php/S025-server-validation.md +63 -0
- package/skill-assets/sunlint-code-quality/rules/php/S026-tls-encryption.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/php/S027-mtls-validation.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/php/S028-upload-limits.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/php/S029-csrf-protection.md +65 -0
- package/skill-assets/sunlint-code-quality/rules/php/S030-directory-browsing.md +40 -0
- package/skill-assets/sunlint-code-quality/rules/php/S031-secure-cookie-flag.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/php/S032-httponly-cookie.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/S033-samesite-cookie.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/php/S034-host-prefix-cookie.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/php/S035-app-hostnames.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/php/S036-internal-file-paths.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/php/S037-anti-cache-headers.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/php/S039-tls-certificate-validation.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/S041-logout-invalidation.md +63 -0
- package/skill-assets/sunlint-code-quality/rules/php/S042-long-lived-sessions.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/php/S044-critical-changes-reauth.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/php/S045-brute-force-protection.md +67 -0
- package/skill-assets/sunlint-code-quality/rules/php/S047-oauth-csrf-protection.md +72 -0
- package/skill-assets/sunlint-code-quality/rules/php/S048-oauth-redirect-validation.md +54 -0
- package/skill-assets/sunlint-code-quality/rules/php/S049-auth-code-expiry.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/php/S050-token-entropy.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/php/S051-password-length.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/php/S052-otp-entropy.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/php/S053-generic-error-messages.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/php/S054-no-default-admin.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/php/S055-content-type-validation.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/php/S056-log-injection.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/php/S057-synchronized-time.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/php/S058-ssrf-protection.md +65 -0
- package/skill-assets/sunlint-code-quality/rules/python/C006-verb-noun-functions.md +30 -0
- package/skill-assets/sunlint-code-quality/rules/python/C013-no-dead-code.md +24 -0
- package/skill-assets/sunlint-code-quality/rules/python/C014-dependency-injection.md +68 -0
- package/skill-assets/sunlint-code-quality/rules/python/C017-no-constructor-logic.md +30 -0
- package/skill-assets/sunlint-code-quality/rules/python/C018-generic-errors.md +25 -0
- package/skill-assets/sunlint-code-quality/rules/python/C019-error-log-level.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/python/C020-no-unused-imports.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/python/C022-no-unused-variables.md +24 -0
- package/skill-assets/sunlint-code-quality/rules/python/C023-no-duplicate-names.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/python/C024-centralize-constants.md +27 -0
- package/skill-assets/sunlint-code-quality/rules/python/C029-catch-log-root-cause.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/python/C030-custom-error-classes.md +28 -0
- package/skill-assets/sunlint-code-quality/rules/python/C033-separate-data-access.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/python/C035-error-context-logging.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/python/C041-no-hardcoded-secrets.md +23 -0
- package/skill-assets/sunlint-code-quality/rules/python/C042-boolean-naming.md +24 -0
- package/skill-assets/sunlint-code-quality/rules/python/C052-controller-parsing.md +34 -0
- package/skill-assets/sunlint-code-quality/rules/python/C060-superclass-logic.md +26 -0
- package/skill-assets/sunlint-code-quality/rules/python/C067-no-hardcoded-config.md +22 -0
- package/skill-assets/sunlint-code-quality/rules/python/S003-open-redirect.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S004-no-log-credentials.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S005-server-authorization.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S006-default-credentials.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S007-output-encoding.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S009-approved-crypto.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S010-csprng.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S011-encrypted-client-hello.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S012-secrets-management.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S013-tls-connections.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S016-no-sensitive-query-string.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S017-parameterized-queries.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/python/S019-email-input-sanitization.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S020-eval-code-execution.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/python/S022-context-escaping.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S023-dynamic-js-encoding.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S025-server-validation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S026-tls-encryption.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S027-mtls-validation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S028-upload-limits.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S029-csrf-protection.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S030-directory-browsing.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S031-secure-cookie-flag.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S032-httponly-cookie.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S033-samesite-cookie.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S034-host-prefix-cookie.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S035-app-hostnames.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S036-internal-file-paths.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/python/S037-anti-cache-headers.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S039-tls-certificate-validation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S041-logout-invalidation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S042-long-lived-sessions.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S044-critical-changes-reauth.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S045-brute-force-protection.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S047-oauth-csrf-protection.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S048-oauth-redirect-validation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S049-auth-code-expiry.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S050-token-entropy.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S051-password-length.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S052-otp-entropy.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S053-generic-error-messages.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S054-no-default-admin.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S055-content-type-validation.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S056-log-injection.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S057-synchronized-time.md +16 -0
- package/skill-assets/sunlint-code-quality/rules/python/S058-ssrf-protection.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C006-verb-noun-functions.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C013-no-dead-code.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C014-dependency-injection.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C017-no-constructor-logic.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C018-generic-errors.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C019-error-log-level.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C020-no-unused-imports.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C022-no-unused-variables.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C023-no-duplicate-names.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C024-centralize-constants.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C029-catch-log-root-cause.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C030-custom-error-classes.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C033-separate-data-access.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C035-error-context-logging.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C041-no-hardcoded-secrets.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C042-boolean-naming.md +42 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C052-controller-parsing.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C060-superclass-logic.md +67 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/C067-no-hardcoded-config.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S003-open-redirect.md +76 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S004-no-log-credentials.md +71 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S005-server-authorization.md +68 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S006-default-credentials.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S007-output-encoding.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S009-approved-crypto.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S010-csprng.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S011-encrypted-client-hello.md +45 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S012-secrets-management.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S013-tls-connections.md +70 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S016-no-sensitive-query-string.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S017-parameterized-queries.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S019-email-input-sanitization.md +56 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S020-eval-code-execution.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S022-context-escaping.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S023-dynamic-js-encoding.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S025-server-validation.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S026-tls-encryption.md +47 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S027-mtls-validation.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S028-upload-limits.md +65 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S029-csrf-protection.md +62 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S030-directory-browsing.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S031-secure-cookie-flag.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S032-httponly-cookie.md +36 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S033-samesite-cookie.md +46 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S034-host-prefix-cookie.md +50 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S035-app-hostnames.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S036-internal-file-paths.md +53 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S037-anti-cache-headers.md +52 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S039-tls-certificate-validation.md +51 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S041-logout-invalidation.md +58 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S042-long-lived-sessions.md +55 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S044-critical-changes-reauth.md +69 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S045-brute-force-protection.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S047-oauth-csrf-protection.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S048-oauth-redirect-validation.md +59 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S049-auth-code-expiry.md +73 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S050-token-entropy.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S051-password-length.md +60 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S052-otp-entropy.md +49 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S053-generic-error-messages.md +61 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S054-no-default-admin.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S055-content-type-validation.md +64 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S056-log-injection.md +48 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S057-synchronized-time.md +57 -0
- package/skill-assets/sunlint-code-quality/rules/typescript/S058-ssrf-protection.md +63 -0
package/origin-rules/dart-en.md
CHANGED
|
@@ -7,283 +7,271 @@
|
|
|
7
7
|
- **Objective**: Ensure code quality through standard lint configurations
|
|
8
8
|
- **Details**: The `analysis_options.yaml` file should include recommended lint packages (flutter_lints, very_good_analysis, or lints) and critical lint rules should not be disabled. This ensures consistent code quality standards across the project.
|
|
9
9
|
- **Applies to**: Flutter/Dart
|
|
10
|
-
- **Tools**:
|
|
10
|
+
- **Tools**: Custom analyzer (D001)
|
|
11
11
|
- **Principles**: CODE_QUALITY
|
|
12
12
|
- **Version**: 1.0
|
|
13
13
|
- **Status**: activated
|
|
14
14
|
- **Severity**: major
|
|
15
15
|
|
|
16
|
-
### 📘 Rule D002 –
|
|
16
|
+
### 📘 Rule D002 – Always Dispose Resources and Remove Listeners
|
|
17
17
|
|
|
18
|
-
- **Objective**:
|
|
19
|
-
- **Details**:
|
|
18
|
+
- **Objective**: Prevent memory leaks by ensuring proper resource disposal
|
|
19
|
+
- **Details**: All disposable resources (Controllers, StreamSubscriptions, FocusNodes, Listeners) must be properly disposed in the `dispose()` method. This includes TextEditingController, AnimationController, ScrollController, StreamSubscription, FocusNode, and other resources that implement Disposable. Failing to dispose these resources leads to memory leaks.
|
|
20
20
|
- **Applies to**: Flutter/Dart
|
|
21
|
-
- **Tools**:
|
|
22
|
-
- **Principles**: CODE_QUALITY
|
|
21
|
+
- **Tools**: Custom analyzer (D002)
|
|
22
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE
|
|
23
23
|
- **Version**: 1.0
|
|
24
24
|
- **Status**: activated
|
|
25
|
-
- **Severity**:
|
|
25
|
+
- **Severity**: error
|
|
26
26
|
|
|
27
|
-
### 📘 Rule D003 –
|
|
27
|
+
### 📘 Rule D003 – Prefer Widgets Over Methods Returning Widgets
|
|
28
28
|
|
|
29
|
-
- **Objective**:
|
|
30
|
-
- **Details**:
|
|
29
|
+
- **Objective**: Improve performance and maintainability by extracting widget-returning methods into widget classes
|
|
30
|
+
- **Details**: Methods that return widgets should be extracted into separate StatelessWidget or StatefulWidget classes. This improves performance as Flutter can optimize widget rebuilds, makes code more reusable, and follows Flutter best practices. Only the build() method and lifecycle methods are exempt from this rule.
|
|
31
31
|
- **Applies to**: Flutter/Dart
|
|
32
|
-
- **Tools**:
|
|
33
|
-
- **Principles**: CODE_QUALITY,
|
|
32
|
+
- **Tools**: Custom analyzer (D003)
|
|
33
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE
|
|
34
34
|
- **Version**: 1.0
|
|
35
35
|
- **Status**: activated
|
|
36
|
-
- **Severity**:
|
|
36
|
+
- **Severity**: warning
|
|
37
37
|
|
|
38
|
-
### 📘 Rule D004 –
|
|
38
|
+
### 📘 Rule D004 – Avoid shrinkWrap in ListView
|
|
39
39
|
|
|
40
|
-
- **Objective**:
|
|
41
|
-
- **Details**:
|
|
40
|
+
- **Objective**: Prevent performance issues caused by shrinkWrap in scrollable widgets
|
|
41
|
+
- **Details**: Using `shrinkWrap: true` in ListView or GridView disables lazy loading and forces all items to render at once, causing severe performance degradation. Instead, use Expanded or Flexible widgets to constrain the ListView size, or use SliverList within a CustomScrollView for better performance. The shrinkWrap parameter should only be used in rare cases where the list is guaranteed to be small.
|
|
42
42
|
- **Applies to**: Flutter/Dart
|
|
43
|
-
- **Tools**:
|
|
44
|
-
- **Principles**: CODE_QUALITY
|
|
43
|
+
- **Tools**: Custom analyzer (D004)
|
|
44
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE
|
|
45
45
|
- **Version**: 1.0
|
|
46
46
|
- **Status**: activated
|
|
47
|
-
- **Severity**:
|
|
47
|
+
- **Severity**: warning
|
|
48
48
|
|
|
49
|
-
### 📘 Rule D005 –
|
|
49
|
+
### 📘 Rule D005 – Limit Widget Nesting Depth to 6
|
|
50
50
|
|
|
51
|
-
- **Objective**:
|
|
52
|
-
- **Details**:
|
|
53
|
-
- Avoid `dynamic` returns or unclear type inference
|
|
54
|
-
- Helps analyzer perform more complete code analysis to find potential runtime errors
|
|
51
|
+
- **Objective**: Maintain code readability and prevent performance issues caused by deeply nested widgets
|
|
52
|
+
- **Details**: Widget nesting should not exceed 6 levels in the build method. Deeply nested widgets make code harder to understand, maintain, and can impact performance. When nesting exceeds this limit, extract nested widgets into separate StatelessWidget or StatefulWidget classes. This improves code organization, reusability, and allows Flutter to optimize widget rebuilds more effectively.
|
|
55
53
|
- **Applies to**: Flutter/Dart
|
|
56
|
-
- **Tools**:
|
|
57
|
-
- **Principles**: CODE_QUALITY
|
|
54
|
+
- **Tools**: Custom analyzer (D005)
|
|
55
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, PERFORMANCE
|
|
58
56
|
- **Version**: 1.0
|
|
59
57
|
- **Status**: activated
|
|
60
|
-
- **Severity**:
|
|
58
|
+
- **Severity**: warning
|
|
61
59
|
|
|
62
|
-
### 📘 Rule D006 –
|
|
60
|
+
### 📘 Rule D006 – Prefer Extracting Large Callbacks from Build
|
|
63
61
|
|
|
64
|
-
- **Objective**:
|
|
65
|
-
- **Details**:
|
|
62
|
+
- **Objective**: Improve code readability and testability by extracting large callback functions
|
|
63
|
+
- **Details**: Callback functions (onTap, onPressed, onChanged, etc.) in widget builders should not exceed 5 lines. Large inline callbacks make the build method harder to read and maintain. Extract callbacks that exceed this limit to separate methods or functions. This improves code organization, makes the build method more readable, and allows callbacks to be tested independently. Common callback properties include onTap, onPressed, onChanged, onSubmitted, onLongPress, builder, and itemBuilder.
|
|
66
64
|
- **Applies to**: Flutter/Dart
|
|
67
|
-
- **Tools**:
|
|
68
|
-
- **Principles**: CODE_QUALITY
|
|
65
|
+
- **Tools**: Custom analyzer (D006)
|
|
66
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, TESTABILITY
|
|
69
67
|
- **Version**: 1.0
|
|
70
68
|
- **Status**: activated
|
|
71
|
-
- **Severity**:
|
|
69
|
+
- **Severity**: warning
|
|
72
70
|
|
|
73
|
-
### 📘 Rule D007 –
|
|
71
|
+
### 📘 Rule D007 – Prefer Init First, Dispose Last
|
|
74
72
|
|
|
75
|
-
- **Objective**:
|
|
76
|
-
- **Details**:
|
|
73
|
+
- **Objective**: Ensure proper lifecycle method ordering in StatefulWidget
|
|
74
|
+
- **Details**: In StatefulWidget lifecycle methods, super.initState() should be called first before any initialization code, and super.dispose() should be called last after all cleanup code. This ensures that the framework's internal state management is properly initialized before your code runs and is the last to clean up. Calling super.initState() first allows the framework to set up necessary internal state before your initialization logic. Calling super.dispose() last ensures all your cleanup code executes before the framework's cleanup, preventing potential null pointer exceptions or resource leaks.
|
|
77
75
|
- **Applies to**: Flutter/Dart
|
|
78
|
-
- **Tools**:
|
|
79
|
-
- **Principles**: CODE_QUALITY,
|
|
76
|
+
- **Tools**: Custom analyzer (D007)
|
|
77
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, LIFECYCLE_MANAGEMENT
|
|
80
78
|
- **Version**: 1.0
|
|
81
79
|
- **Status**: activated
|
|
82
|
-
- **Severity**:
|
|
80
|
+
- **Severity**: warning
|
|
83
81
|
|
|
84
|
-
### 📘 Rule D008 – Avoid
|
|
85
|
-
|
|
86
|
-
- **Objective**:
|
|
87
|
-
- **Details**:
|
|
88
|
-
- `Directory.exists`
|
|
89
|
-
- `Directory.stat`
|
|
90
|
-
- `File.lastModified`
|
|
91
|
-
- `File.exists`
|
|
92
|
-
- `File.stat`
|
|
93
|
-
- `FileSystemEntity.isDirectory`
|
|
94
|
-
- `FileSystemEntity.isFile`
|
|
95
|
-
- `FileSystemEntity.isLink`
|
|
96
|
-
- `FileSystemEntity.type`
|
|
82
|
+
### 📘 Rule D008 – Avoid Long Functions
|
|
83
|
+
|
|
84
|
+
- **Objective**: Improve code readability and maintainability by limiting function length
|
|
85
|
+
- **Details**: Functions should not exceed 60 lines of effective code (excluding comments and opening/closing braces). Long functions are harder to understand, test, and maintain. They often indicate that the function is doing too much and should be broken down into smaller, more focused functions. The line count excludes blank lines, comments (both single-line // and multi-line /* */), and the opening { and closing } braces. The maximum line limit is configurable.
|
|
97
86
|
- **Applies to**: Flutter/Dart
|
|
98
|
-
- **Tools**:
|
|
99
|
-
- **Principles**: CODE_QUALITY,
|
|
87
|
+
- **Tools**: Custom analyzer (D008)
|
|
88
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
100
89
|
- **Version**: 1.0
|
|
101
90
|
- **Status**: activated
|
|
102
|
-
- **Severity**:
|
|
91
|
+
- **Severity**: warning
|
|
103
92
|
|
|
104
|
-
### 📘 Rule D009 –
|
|
93
|
+
### 📘 Rule D009 – Limit Function Parameters
|
|
105
94
|
|
|
106
|
-
- **Objective**:
|
|
107
|
-
- **Details**:
|
|
95
|
+
- **Objective**: Improve code readability by limiting the number of function parameters
|
|
96
|
+
- **Details**: Functions, methods, and constructors should not have more than 5 parameters (configurable). Too many parameters make code harder to read, understand, and maintain. When a function needs many parameters, consider grouping related parameters into a data class or using named parameters with a configuration object.
|
|
108
97
|
- **Applies to**: Flutter/Dart
|
|
109
|
-
- **Tools**:
|
|
110
|
-
- **Principles**: CODE_QUALITY
|
|
98
|
+
- **Tools**: Custom analyzer (D009)
|
|
99
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
111
100
|
- **Version**: 1.0
|
|
112
101
|
- **Status**: activated
|
|
113
|
-
- **Severity**:
|
|
102
|
+
- **Severity**: warning
|
|
114
103
|
|
|
115
|
-
### 📘 Rule D010 –
|
|
104
|
+
### 📘 Rule D010 – Limit Cyclomatic Complexity
|
|
116
105
|
|
|
117
|
-
- **Objective**:
|
|
118
|
-
- **Details**:
|
|
106
|
+
- **Objective**: Improve code readability and maintainability by limiting cyclomatic complexity
|
|
107
|
+
- **Details**: Functions, methods, and constructors should not have cyclomatic complexity exceeding 10 (configurable). High cyclomatic complexity indicates that the code has too many independent paths, making it harder to understand, test, and maintain. The metric counts: if statements, catch blocks, loops (for, while, do), conditional expressions (? :), switch cases (except default/last), null-aware operators (?., ?[], ...?, ??), logical operators (&& and ||), and null coalescing operators (?? and ??=).
|
|
119
108
|
- **Applies to**: Flutter/Dart
|
|
120
|
-
- **Tools**:
|
|
121
|
-
- **Principles**: CODE_QUALITY
|
|
109
|
+
- **Tools**: Custom analyzer (D010)
|
|
110
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
122
111
|
- **Version**: 1.0
|
|
123
112
|
- **Status**: activated
|
|
124
|
-
- **Severity**:
|
|
113
|
+
- **Severity**: warning
|
|
125
114
|
|
|
126
|
-
### 📘 Rule D011 –
|
|
115
|
+
### 📘 Rule D011 – Prefer Named Parameters
|
|
127
116
|
|
|
128
|
-
- **Objective**:
|
|
129
|
-
- **Details**:
|
|
117
|
+
- **Objective**: Improve code readability and prevent parameter confusion
|
|
118
|
+
- **Details**: Functions, methods, and constructors with more than 3 parameters that have 2 or more adjacent parameters of the same type should use named parameters. This improves code clarity by making it explicit which value corresponds to which parameter, reducing the risk of accidentally swapping arguments of the same type. Named parameters make function calls self-documenting and easier to maintain.
|
|
130
119
|
- **Applies to**: Flutter/Dart
|
|
131
|
-
- **Tools**:
|
|
132
|
-
- **Principles**: CODE_QUALITY,
|
|
120
|
+
- **Tools**: Custom analyzer (D011)
|
|
121
|
+
- **Principles**: CODE_QUALITY, READABILITY, MAINTAINABILITY
|
|
133
122
|
- **Version**: 1.0
|
|
134
123
|
- **Status**: activated
|
|
135
|
-
- **Severity**:
|
|
124
|
+
- **Severity**: warning
|
|
136
125
|
|
|
137
|
-
### 📘 Rule D012 –
|
|
126
|
+
### 📘 Rule D012 – Prefer Named Boolean Parameters
|
|
138
127
|
|
|
139
|
-
- **Objective**:
|
|
140
|
-
- **Details**:
|
|
128
|
+
- **Objective**: Improve code readability by avoiding unclear boolean parameters
|
|
129
|
+
- **Details**: Boolean parameters in functions make code harder to understand at call sites. When a function has 1-2 parameters with a boolean, consider creating separate functions (e.g., `enableUser`/`disableUser` instead of `setUser(userId, true)`). For functions with multiple parameters including booleans, use named parameters to make the intent explicit (e.g., `createUser(name: 'John', isActive: true)` instead of `createUser('John', true)`).
|
|
141
130
|
- **Applies to**: Flutter/Dart
|
|
142
|
-
- **Tools**:
|
|
143
|
-
- **Principles**: CODE_QUALITY,
|
|
131
|
+
- **Tools**: Custom analyzer (D012)
|
|
132
|
+
- **Principles**: CODE_QUALITY, READABILITY, MAINTAINABILITY
|
|
144
133
|
- **Version**: 1.0
|
|
145
134
|
- **Status**: activated
|
|
146
|
-
- **Severity**:
|
|
135
|
+
- **Severity**: warning
|
|
147
136
|
|
|
148
|
-
### 📘 Rule D013 –
|
|
137
|
+
### 📘 Rule D013 – Prefer a Single Public Class Per File
|
|
149
138
|
|
|
150
|
-
- **Objective**:
|
|
151
|
-
- **Details**:
|
|
139
|
+
- **Objective**: Improve code organization and maintainability
|
|
140
|
+
- **Details**: Each Dart file should contain only one public class (class names not starting with underscore). Multiple public classes in a single file make code harder to navigate, test, and maintain. Private classes (names starting with `_`) can coexist with a single public class as they are implementation details. This rule encourages better file organization and follows Dart's convention of one public declaration per file.
|
|
152
141
|
- **Applies to**: Flutter/Dart
|
|
153
|
-
- **Tools**:
|
|
154
|
-
- **Principles**: CODE_QUALITY,
|
|
142
|
+
- **Tools**: Custom analyzer (D013)
|
|
143
|
+
- **Principles**: CODE_QUALITY, ORGANIZATION, MAINTAINABILITY
|
|
155
144
|
- **Version**: 1.0
|
|
156
145
|
- **Status**: activated
|
|
157
|
-
- **Severity**:
|
|
146
|
+
- **Severity**: warning
|
|
158
147
|
|
|
159
|
-
### 📘 Rule D014 –
|
|
148
|
+
### 📘 Rule D014 – Avoid Unsafe Collection Access
|
|
160
149
|
|
|
161
|
-
- **Objective**:
|
|
162
|
-
- **Details**:
|
|
150
|
+
- **Objective**: Prevent runtime errors from accessing empty collections
|
|
151
|
+
- **Details**: Using `.first`, `.last`, `.single`, or `.elementAt()` on collections without checking if they're empty or have sufficient length can cause runtime exceptions. Always check `isEmpty`, `isNotEmpty`, or `length` before accessing, or use safe alternatives like `firstOrNull`, `lastOrNull`, `singleOrNull`. These methods throw `StateError` when the collection is empty or doesn't meet the required conditions, leading to crashes in production.
|
|
163
152
|
- **Applies to**: Flutter/Dart
|
|
164
|
-
- **Tools**:
|
|
165
|
-
- **Principles**: CODE_QUALITY,
|
|
153
|
+
- **Tools**: Custom analyzer (D014)
|
|
154
|
+
- **Principles**: CODE_QUALITY, SAFETY, ERROR_PREVENTION
|
|
166
155
|
- **Version**: 1.0
|
|
167
156
|
- **Status**: activated
|
|
168
|
-
- **Severity**:
|
|
157
|
+
- **Severity**: warning
|
|
169
158
|
|
|
170
|
-
### 📘 Rule D015 –
|
|
159
|
+
### 📘 Rule D015 – Ensure copyWith includes all constructor parameters
|
|
171
160
|
|
|
172
|
-
- **Objective**:
|
|
173
|
-
- **Details**:
|
|
161
|
+
- **Objective**: Maintain data integrity and completeness in immutable objects
|
|
162
|
+
- **Details**: When a class implements a `copyWith` method for creating modified copies, it should include all constructor parameters. Missing parameters in `copyWith` can lead to unintended data loss or inability to update certain fields. This is especially important for data classes, models, and immutable state objects.
|
|
174
163
|
- **Applies to**: Flutter/Dart
|
|
175
|
-
- **Tools**:
|
|
176
|
-
- **Principles**: CODE_QUALITY
|
|
164
|
+
- **Tools**: Custom analyzer (D015)
|
|
165
|
+
- **Principles**: CODE_QUALITY, IMMUTABILITY, DATA_INTEGRITY
|
|
177
166
|
- **Version**: 1.0
|
|
178
167
|
- **Status**: activated
|
|
179
|
-
- **Severity**:
|
|
168
|
+
- **Severity**: warning
|
|
180
169
|
|
|
181
|
-
### 📘 Rule D016 –
|
|
170
|
+
### 📘 Rule D016 – Project should have tests
|
|
182
171
|
|
|
183
|
-
- **Objective**:
|
|
184
|
-
- **Details**:
|
|
172
|
+
- **Objective**: Ensure code quality and prevent regressions through automated testing
|
|
173
|
+
- **Details**: Every Dart/Flutter project should have a `test` directory containing test files (files ending with `_test.dart`). Tests are essential for maintaining code quality, catching bugs early, and enabling safe refactoring. Without tests, code changes become risky and technical debt accumulates. Projects should have at least one test file to demonstrate testing infrastructure is in place.
|
|
185
174
|
- **Applies to**: Flutter/Dart
|
|
186
|
-
- **Tools**:
|
|
187
|
-
- **Principles**: CODE_QUALITY
|
|
175
|
+
- **Tools**: Custom analyzer (D016)
|
|
176
|
+
- **Principles**: CODE_QUALITY, TESTING, MAINTAINABILITY
|
|
188
177
|
- **Version**: 1.0
|
|
189
178
|
- **Status**: activated
|
|
190
|
-
- **Severity**:
|
|
179
|
+
- **Severity**: warning
|
|
191
180
|
|
|
192
|
-
### 📘 Rule D017 –
|
|
181
|
+
### 📘 Rule D017 – Pubspec dependencies should be reviewed regularly
|
|
193
182
|
|
|
194
|
-
- **Objective**:
|
|
195
|
-
- **Details**:
|
|
183
|
+
- **Objective**: Ensure dependencies are kept up-to-date for security and stability
|
|
184
|
+
- **Details**: Dependencies in `pubspec.yaml` should be reviewed and updated regularly (default: every 4 months). Outdated dependencies may contain security vulnerabilities, bugs, or miss performance improvements. Regular reviews help maintain project health and reduce technical debt. The rule checks the last modification time of `pubspec.lock` (or `pubspec.yaml` if lock file is not available) and warns if it exceeds the configured threshold. This encourages teams to regularly audit dependencies, update to newer versions, and test for compatibility issues.
|
|
196
185
|
- **Applies to**: Flutter/Dart
|
|
197
|
-
- **Tools**:
|
|
198
|
-
- **Principles**: CODE_QUALITY
|
|
186
|
+
- **Tools**: Custom analyzer (D017)
|
|
187
|
+
- **Principles**: SECURITY, MAINTAINABILITY, CODE_QUALITY
|
|
199
188
|
- **Version**: 1.0
|
|
200
189
|
- **Status**: activated
|
|
201
|
-
- **Severity**:
|
|
190
|
+
- **Severity**: warning
|
|
202
191
|
|
|
203
|
-
### 📘 Rule D018 –
|
|
192
|
+
### 📘 Rule D018 – Remove Commented-Out Code
|
|
204
193
|
|
|
205
|
-
- **Objective**:
|
|
206
|
-
- **Details**:
|
|
194
|
+
- **Objective**: Keep codebase clean by removing commented-out code
|
|
195
|
+
- **Details**: Commented-out code should be removed instead of being left in the source files. Dead code comments create clutter, make the codebase harder to read, and cause confusion about what code is actually active. If you need to reference old code, use version control systems (Git) to track history. The rule detects blocks of 2 or more consecutive lines that appear to be commented-out code (containing keywords like var, if, class, function calls, operators, etc.) and suggests removing them. Documentation comments (///, /**) are excluded from this check.
|
|
207
196
|
- **Applies to**: Flutter/Dart
|
|
208
|
-
- **Tools**:
|
|
209
|
-
- **Principles**: CODE_QUALITY
|
|
197
|
+
- **Tools**: Custom analyzer (D018)
|
|
198
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
210
199
|
- **Version**: 1.0
|
|
211
200
|
- **Status**: activated
|
|
212
|
-
- **Severity**:
|
|
201
|
+
- **Severity**: warning
|
|
213
202
|
|
|
214
|
-
### 📘 Rule D019 –
|
|
203
|
+
### 📘 Rule D019 – Avoid Single Child in Multi-Child Widget
|
|
215
204
|
|
|
216
|
-
- **Objective**:
|
|
217
|
-
- **Details**:
|
|
205
|
+
- **Objective**: Use appropriate widget types for the number of children
|
|
206
|
+
- **Details**: Multi-child widgets like Column, Row, Wrap, Stack, Flex, ListView, GridView, and CustomScrollView are designed to handle multiple children (via `children` or `slivers` parameters). Using these widgets with only a single child or sliver is inefficient and indicates poor widget choice. Instead, use single-child widgets like Container, SizedBox, Padding, or Center which are optimized for single children. This improves performance and makes the code intent clearer.
|
|
218
207
|
- **Applies to**: Flutter/Dart
|
|
219
|
-
- **Tools**:
|
|
220
|
-
- **Principles**: CODE_QUALITY
|
|
208
|
+
- **Tools**: Custom analyzer (D019)
|
|
209
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE, MAINTAINABILITY
|
|
221
210
|
- **Version**: 1.0
|
|
222
211
|
- **Status**: activated
|
|
223
|
-
- **Severity**:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
- **
|
|
228
|
-
- **
|
|
229
|
-
- **
|
|
230
|
-
- **
|
|
231
|
-
- **Principles**: SECURITY
|
|
212
|
+
- **Severity**: warning
|
|
213
|
+
### 📘 Rule D020 – Limit If/Else Branches
|
|
214
|
+
|
|
215
|
+
- **Objective**: Reduce complexity by limiting the number of if/else branches
|
|
216
|
+
- **Details**: Complex if/else chains with more than 3 branches reduce code readability and increase cyclomatic complexity. When facing multiple branches, consider using switch statements, lookup tables (Maps), polymorphism, or strategy pattern. This makes code easier to understand, test, and maintain. The default limit is 3 branches (e.g., if + else if + else).
|
|
217
|
+
- **Applies to**: Dart/Flutter
|
|
218
|
+
- **Tools**: Custom analyzer (D020)
|
|
219
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
232
220
|
- **Version**: 1.0
|
|
233
221
|
- **Status**: activated
|
|
234
|
-
- **Severity**:
|
|
222
|
+
- **Severity**: warning
|
|
235
223
|
|
|
236
|
-
### 📘 Rule D021 –
|
|
224
|
+
### 📘 Rule D021 – Avoid Negated Boolean Checks
|
|
237
225
|
|
|
238
|
-
- **Objective**:
|
|
239
|
-
- **Details**:
|
|
240
|
-
- **Applies to**: Flutter
|
|
241
|
-
- **Tools**:
|
|
242
|
-
- **Principles**: CODE_QUALITY
|
|
226
|
+
- **Objective**: Improve code readability by avoiding inverted or negated boolean conditions
|
|
227
|
+
- **Details**: Negated boolean checks (using `!` operator) make code harder to read and understand. Replace negative conditions with positive ones: use `if (isSuccess)` instead of `if (!isError)`, use `a != b` instead of `!(a == b)`, avoid double negation like `!(!isValid)`. For boolean variables frequently used with negation, consider renaming them to express the positive state (e.g., `isEnabled` instead of using `!isDisabled`). Apply De Morgan's law for compound conditions: `!(a && b)` becomes `!a || !b`.
|
|
228
|
+
- **Applies to**: Dart/Flutter
|
|
229
|
+
- **Tools**: Custom analyzer (D021)
|
|
230
|
+
- **Principles**: CODE_QUALITY, READABILITY
|
|
243
231
|
- **Version**: 1.0
|
|
244
232
|
- **Status**: activated
|
|
245
|
-
- **Severity**:
|
|
233
|
+
- **Severity**: warning
|
|
246
234
|
|
|
247
|
-
### 📘 Rule D022 –
|
|
235
|
+
### 📘 Rule D022 – Use setState Correctly
|
|
248
236
|
|
|
249
|
-
- **Objective**:
|
|
250
|
-
- **Details**:
|
|
237
|
+
- **Objective**: Ensure setState is used correctly in StatefulWidget to avoid performance issues and bugs
|
|
238
|
+
- **Details**: Common setState anti-patterns include: calling setState inside the build() method (causes infinite rebuild loops), nesting setState calls (unnecessary rebuilds), making multiple setState calls in the same method (should be combined for performance), using async callbacks in setState (state updates should be synchronous). Always perform async operations outside setState and combine multiple state changes into a single setState call.
|
|
251
239
|
- **Applies to**: Flutter/Dart
|
|
252
|
-
- **Tools**:
|
|
253
|
-
- **Principles**: CODE_QUALITY
|
|
240
|
+
- **Tools**: Custom analyzer (D022)
|
|
241
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE, BEST_PRACTICES
|
|
254
242
|
- **Version**: 1.0
|
|
255
243
|
- **Status**: activated
|
|
256
|
-
- **Severity**:
|
|
244
|
+
- **Severity**: warning
|
|
257
245
|
|
|
258
|
-
### 📘 Rule D023 –
|
|
246
|
+
### 📘 Rule D023 – Avoid Unnecessary Method Overrides
|
|
259
247
|
|
|
260
|
-
- **Objective**:
|
|
261
|
-
- **Details**:
|
|
262
|
-
- **Applies to**: Flutter
|
|
263
|
-
- **Tools**:
|
|
264
|
-
- **Principles**: CODE_QUALITY,
|
|
248
|
+
- **Objective**: Remove methods that only call super with the same parameters as they add no value
|
|
249
|
+
- **Details**: Methods that override a parent method but only call `super.methodName()` with the same parameters are unnecessary and should be removed. These empty overrides add no functionality and create unnecessary code clutter. Common examples include lifecycle methods like `initState()`, `dispose()`, or `didUpdateWidget()` that only call their super implementation. Removing these unnecessary overrides improves code readability and reduces maintenance burden.
|
|
250
|
+
- **Applies to**: Dart/Flutter
|
|
251
|
+
- **Tools**: Custom analyzer (D023)
|
|
252
|
+
- **Principles**: CODE_QUALITY, MAINTAINABILITY, READABILITY
|
|
265
253
|
- **Version**: 1.0
|
|
266
254
|
- **Status**: activated
|
|
267
|
-
- **Severity**:
|
|
255
|
+
- **Severity**: warning
|
|
268
256
|
|
|
269
|
-
### 📘 Rule D024 –
|
|
257
|
+
### 📘 Rule D024 – Avoid Unnecessary StatefulWidget
|
|
270
258
|
|
|
271
|
-
- **Objective**:
|
|
272
|
-
- **Details**:
|
|
259
|
+
- **Objective**: Use StatelessWidget when no state management is needed to improve performance
|
|
260
|
+
- **Details**: StatefulWidget should only be used when the widget needs to maintain mutable state that changes over time. If a widget extends StatefulWidget but its State class has no mutable fields, never calls setState(), and doesn't use lifecycle methods beyond build(), it should be converted to StatelessWidget. StatelessWidget is more efficient as it doesn't maintain state and has less overhead. This rule detects StatefulWidget classes where the State has no mutable fields, no setState() calls, and no state-related lifecycle methods.
|
|
273
261
|
- **Applies to**: Flutter/Dart
|
|
274
|
-
- **Tools**:
|
|
275
|
-
- **Principles**: CODE_QUALITY,
|
|
262
|
+
- **Tools**: Custom analyzer (D024)
|
|
263
|
+
- **Principles**: CODE_QUALITY, PERFORMANCE, BEST_PRACTICES
|
|
276
264
|
- **Version**: 1.0
|
|
277
265
|
- **Status**: activated
|
|
278
|
-
- **Severity**:
|
|
266
|
+
- **Severity**: warning
|
|
279
267
|
|
|
280
|
-
### 📘 Rule D025 –
|
|
268
|
+
### 📘 Rule D025 – Avoid Nested Conditional Expressions
|
|
281
269
|
|
|
282
|
-
- **Objective**:
|
|
283
|
-
- **Details**:
|
|
284
|
-
- **Applies to**: Flutter
|
|
285
|
-
- **Tools**:
|
|
286
|
-
- **Principles**: CODE_QUALITY,
|
|
270
|
+
- **Objective**: Improve code readability by avoiding nested ternary operators
|
|
271
|
+
- **Details**: Nested conditional expressions (ternary operators like `condition ? value1 : value2`) reduce code readability and make logic harder to understand. When ternary operators are nested within the then or else branches of another ternary, the code becomes difficult to follow. Instead, use if-else statements for complex conditional logic, or extract the logic into a well-named function. Simple, non-nested ternary operators are acceptable for straightforward cases, but nesting should always be avoided.
|
|
272
|
+
- **Applies to**: Dart/Flutter
|
|
273
|
+
- **Tools**: Custom analyzer (D025)
|
|
274
|
+
- **Principles**: CODE_QUALITY, READABILITY, MAINTAINABILITY
|
|
287
275
|
- **Version**: 1.0
|
|
288
276
|
- **Status**: activated
|
|
289
|
-
- **Severity**:
|
|
277
|
+
- **Severity**: warning
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sun-asterisk/sunlint",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.40",
|
|
4
4
|
"description": "☀️ SunLint - Multi-language static analysis tool for code quality and security | Sun* Engineering Standards",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"scripts/",
|
|
42
42
|
"templates/",
|
|
43
43
|
"docs/",
|
|
44
|
+
"skill-assets/",
|
|
44
45
|
".sunlint.json",
|
|
45
46
|
"README.md",
|
|
46
47
|
"LICENSE",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D002",
|
|
3
|
+
"name": "Always Dispose Resources and Remove Listeners",
|
|
4
|
+
"description": "Ensure all resources (Controllers, StreamSubscriptions, FocusNodes, Listeners) are properly disposed in the dispose() method to prevent memory leaks",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "error",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "memory-leak", "resource-management", "dispose"],
|
|
9
|
+
"config": {
|
|
10
|
+
"disposableTypes": [
|
|
11
|
+
"Controller",
|
|
12
|
+
"StreamSubscription",
|
|
13
|
+
"FocusNode",
|
|
14
|
+
"AnimationController",
|
|
15
|
+
"TextEditingController",
|
|
16
|
+
"ScrollController",
|
|
17
|
+
"TabController",
|
|
18
|
+
"PageController",
|
|
19
|
+
"VideoPlayerController",
|
|
20
|
+
"CameraController"
|
|
21
|
+
],
|
|
22
|
+
"checkListeners": true,
|
|
23
|
+
"checkSubscriptions": true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D003",
|
|
3
|
+
"name": "Prefer Widgets Over Methods Returning Widgets",
|
|
4
|
+
"description": "Extract methods returning widgets into separate widget classes for better performance and maintainability",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "widget", "performance", "best-practice"],
|
|
9
|
+
"config": {
|
|
10
|
+
"excludePrivateMethods": false,
|
|
11
|
+
"excludeBuildHelpers": false,
|
|
12
|
+
"minMethodLength": 3
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D004",
|
|
3
|
+
"name": "Avoid shrinkWrap in ListView",
|
|
4
|
+
"description": "ListView with shrinkWrap: true causes performance issues. Use Expanded/Flexible or SliverList instead",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "performance", "listview", "best-practice"],
|
|
9
|
+
"config": {
|
|
10
|
+
"checkTypes": ["ListView", "GridView"],
|
|
11
|
+
"message": "Avoid using shrinkWrap: true as it disables lazy loading and forces the ListView to render all items at once, causing performance issues"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D005",
|
|
3
|
+
"name": "Limit Widget Nesting Depth to 6",
|
|
4
|
+
"description": "Widget nesting should not exceed 6 levels to maintain code readability and performance",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "widget", "complexity", "readability", "nesting"],
|
|
9
|
+
"config": {
|
|
10
|
+
"maxDepth": 6,
|
|
11
|
+
"excludePatterns": ["_State", "Mixin"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D006",
|
|
3
|
+
"name": "Prefer Extracting Large Callbacks from Build",
|
|
4
|
+
"description": "Large callback functions in widget builders should be extracted to separate methods for better readability and maintainability",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "widget", "callback", "readability"],
|
|
9
|
+
"config": {
|
|
10
|
+
"maxLines": 5,
|
|
11
|
+
"callbackProperties": [
|
|
12
|
+
"onTap",
|
|
13
|
+
"onPressed",
|
|
14
|
+
"onChanged",
|
|
15
|
+
"onSubmitted",
|
|
16
|
+
"onSaved",
|
|
17
|
+
"onLongPress",
|
|
18
|
+
"onDoubleTap",
|
|
19
|
+
"builder",
|
|
20
|
+
"itemBuilder",
|
|
21
|
+
"onRefresh",
|
|
22
|
+
"onPageChanged"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D007",
|
|
3
|
+
"name": "Prefer Init First, Dispose Last",
|
|
4
|
+
"description": "Code should be called after super.initState() and before super.dispose()",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["flutter", "lifecycle", "state-management"],
|
|
9
|
+
"config": {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D008",
|
|
3
|
+
"name": "Avoid Long Functions",
|
|
4
|
+
"description": "Functions should not exceed the maximum line limit",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["readability", "maintainability", "complexity"],
|
|
9
|
+
"config": {
|
|
10
|
+
"maxLines": 60
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D009",
|
|
3
|
+
"name": "Limit Function Parameters",
|
|
4
|
+
"description": "Functions should not have too many parameters to maintain readability. By default, nullable named parameters are not counted as they have implicit null defaults.",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["readability", "maintainability", "complexity"],
|
|
9
|
+
"config": {
|
|
10
|
+
"maxParameters": 5,
|
|
11
|
+
"skipNullableNamedParameters": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "D010",
|
|
3
|
+
"name": "Limit Cyclomatic Complexity",
|
|
4
|
+
"description": "Functions should not have high cyclomatic complexity",
|
|
5
|
+
"category": "dart",
|
|
6
|
+
"severity": "warning",
|
|
7
|
+
"languages": ["dart"],
|
|
8
|
+
"tags": ["complexity", "maintainability", "readability"],
|
|
9
|
+
"config": {
|
|
10
|
+
"maxComplexity": 10
|
|
11
|
+
}
|
|
12
|
+
}
|