Skip to content

Conversation

@riscait
Copy link
Member

@riscait riscait commented May 23, 2025

This PR introduces a new lint rule: avoid_hardcoded_unicode.\n\n- Detects hardcoded string literals containing characters outside a configurable ASCII range (default: 0x20-0x7E).\n- Generalizes the previous avoid_hardcoded_japanese rule.\n- Includes tests and documentation.\n\nPlease review.

Copilot AI review requested due to automatic review settings May 23, 2025 01:27
@riscait riscait requested a review from a team as a code owner May 23, 2025 01:27
@riscait riscait requested review from naipaka and removed request for a team May 23, 2025 01:27
@riscait riscait marked this pull request as draft May 23, 2025 01:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new lint rule, avoid_hardcoded_unicode, generalizing the previous avoid_hardcoded_japanese rule to detect hardcoded string literals containing characters outside the allowed ASCII range.

  • Added rule implementation in packages/altive_lints/lib/src/lints/avoid_hardcoded_unicode.dart
  • Updated rule registration in altive_lints.dart and all_lint_rules.yaml
  • Included tests and examples in the packages/altive_lints/example directory

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/altive_lints/lib/src/lints/avoid_hardcoded_unicode.dart Implements the new lint rule to check for disallowed Unicode characters in string literals and interpolations
packages/altive_lints/lib/altive_lints.dart Registers the new lint rule with the plugin
packages/altive_lints/lib/all_lint_rules.yaml Adds the new lint rule to the configuration
packages/altive_lints/example/test/avoid_hardcoded_unicode.dart Provides test cases ensuring the rule is inactive in test files
packages/altive_lints/example/lints/avoid_hardcoded_unicode_test.dart Confirms the test exemption based on file naming
packages/altive_lints/example/lints/avoid_hardcoded_unicode.dart Tests the rule detection with expected lint comments

});

context.registry.addStringInterpolation((node) {
final stringValue = node.toSource();
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using node.toSource() to retrieve the content of a string interpolation may include extra syntax artifacts from the interpolation itself. Consider extracting just the literal parts if possible to avoid potential false positives.

Suggested change
final stringValue = node.toSource();
final stringValue = node.elements
.whereType<InterpolationString>()
.map((e) => e.value)
.join();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants