lib/pdk/validate/tasks/tasks_name_validator.rb in pdk-2.3.0 vs lib/pdk/validate/tasks/tasks_name_validator.rb in pdk-2.4.0
- old
+ new
@@ -1,50 +1,50 @@
-require 'pdk'
-
-module PDK
- module Validate
- module Tasks
- class TasksNameValidator < InternalRubyValidator
- INVALID_TASK_MSG = _(
- 'Invalid task name. Task names must start with a lowercase letter ' \
- 'and can only contain lowercase letters, numbers, and underscores.',
- )
-
- def name
- 'task-name'
- end
-
- def pattern
- contextual_pattern('tasks/**/*')
- end
-
- def spinner_text
- _('Checking task names (%{pattern}).') % {
- pattern: pattern.join(' '),
- }
- end
-
- def validate_target(report, target)
- task_name = File.basename(target, File.extname(target))
- if PDK::CLI::Util::OptionValidator.valid_task_name?(task_name)
- report.add_event(
- file: target,
- source: name,
- state: :passed,
- severity: 'ok',
- )
- return 0
- else
- report.add_event(
- file: target,
- source: name,
- state: :failure,
- severity: 'error',
- message: INVALID_TASK_MSG,
- )
- return 1
- end
- end
- end
- end
- end
-end
+require 'pdk'
+
+module PDK
+ module Validate
+ module Tasks
+ class TasksNameValidator < InternalRubyValidator
+ INVALID_TASK_MSG = _(
+ 'Invalid task name. Task names must start with a lowercase letter ' \
+ 'and can only contain lowercase letters, numbers, and underscores.',
+ )
+
+ def name
+ 'task-name'
+ end
+
+ def pattern
+ contextual_pattern('tasks/**/*')
+ end
+
+ def spinner_text
+ _('Checking task names (%{pattern}).') % {
+ pattern: pattern.join(' '),
+ }
+ end
+
+ def validate_target(report, target)
+ task_name = File.basename(target, File.extname(target))
+ if PDK::CLI::Util::OptionValidator.valid_task_name?(task_name)
+ report.add_event(
+ file: target,
+ source: name,
+ state: :passed,
+ severity: 'ok',
+ )
+ return 0
+ else
+ report.add_event(
+ file: target,
+ source: name,
+ state: :failure,
+ severity: 'error',
+ message: INVALID_TASK_MSG,
+ )
+ return 1
+ end
+ end
+ end
+ end
+ end
+end