Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update to regex to look for underscore delimited labels #12

Merged
merged 2 commits into from
Feb 22, 2023
Merged

Update to regex to look for underscore delimited labels #12

merged 2 commits into from
Feb 22, 2023

Conversation

eliasyishak
Copy link
Contributor

We have recently decided to make sure that all tool labels are underscore delimited instead of hyphens. This PR fixes the regex pattern for the tool line in the config file. Sample of what a config file looks like is shown below with one tool initialized

# INTRODUCTION
#
# This is the Flutter and Dart telemetry reporting
# configuration file.
#
# Lines starting with a #" are documentation that
# the tools maintain automatically.
#
# All other lines are configuration lines. They have
# the form "name=value". If multiple lines contain
# the same configuration name with different values,
# the parser will default to a conservative value. 

# DISABLING TELEMETRY REPORTING
#
# To disable telemetry reporting, set "reporting" to
# the value "0" and to enable, set to "1":
reporting=1

# NOTIFICATIONS
#
# Each tool records when it last informed the user about
# analytics reporting and the privacy policy.
#
# The following tools have so far read this file:
#
#   dart-tools (Dart CLI developer tool)
#   devtools (DevTools debugging and performance tools)
#   flutter-tools (Flutter CLI developer tool)
#
# For each one, the file may contain a configuration line
# where the name is the code in the list above, e.g. "dart-tool",
# and the value is a date in the form YYYY-MM-DD, a comma, and
# a number representing the version of the message that was
# displayed.
flutter_tools=2023-02-22,1

const String toolPattern =
r'^([A-Za-z0-9]+-*[A-Za-z0-9]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';
r'^([A-Za-z0-9]+_*[A-Za-z0-9]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
r'^([A-Za-z0-9]+_*[A-Za-z0-9]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';
r'^([A-Za-z0-9]+[A-Za-z0-9_]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';

Or to simplify (if we don't mind allowing a leading underscore):

    r'^(\w+)=(\d{4}-\d{2}-\d{2}),(\d+)$';

Copy link
Contributor Author

@eliasyishak eliasyishak Feb 22, 2023

Choose a reason for hiding this comment

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

Good suggestion, I did initially have it that way because I wanted to only have two words in the label, like flutter and tools, and prevent something like flutter_tools_cli but that seems too restrictive in hindsight.

The very simple version though allows for underscores as the first char which i wanted to prevent

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

nit about the exact regex, otherwise LGTM

@eliasyishak eliasyishak merged commit c7518f7 into dart-lang:main Feb 22, 2023
@eliasyishak eliasyishak deleted the fix-tool-pattern-regex branch February 22, 2023 21:30
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants