Skip to content

gdlint: disabling more than once doesn't work #416

@codevogel

Description

@codevogel

Disabling and then enabing a rule works.

But if this happens more than once in a file, the other disable/enables have no effect.

e.g.

## Evaluates the callable with [param args] as arguments.
## Returns either a [code]bool[/code] or an [code]Array[/code] of nested [ValidationCondition]s.
## If the callable does not return a [code]bool[/code] or an [code]Array[/code] of
## [ValidationCondition]s, an error will be pushed and [code]null[/code] will be returned.
func evaluate(args: Array = []) -> Variant:
	var result: Variant = callable.callv(args)
	if typeof(result) == TYPE_BOOL:
		return result
	if typeof(result) == TYPE_ARRAY:
		# Ensure all items in the array are ValidationConditions
		for item in result:
			if typeof(item) != typeof(ValidationCondition):
				#gdlint: disable=max-line-length
				push_error(
					"ValidationCondition Callable returned an array, but not all items are ValidationCondition instances."
				)
				#gdlint: enable=max-line-length
				GodotDoctorPlugin.instance.quit_with_fail_early_if_headless()
				return false
		return result as Array[ValidationCondition]
	push_error(
		"ValidationCondition Callable did not return a boolean or an array of ValidationConditions."
	)
	GodotDoctorPlugin.instance.quit_with_fail_early_if_headless()
	return null

## DEPRECATED: Use [method is_string_not_empty] instead.
static func string_not_empty(
	value: String, variable_name: String = "String", severity_level: Severity = Severity.WARNING
) -> ValidationCondition:
	#gdlint: disable=max-line-length
	push_warning(
		"[ValidationCondition.string_not_empty] is deprecated. Please use [ValidationCondition.is_string_not_empty] instead. (string_not_empty will be removed in a future version. Note that the functionality hasn't changed, just the method name for consistency with other ValidationCondition helpers.)"
	)
	#gdlint: enable=max-line-length
	return is_string_not_empty(value, variable_name, severity_level)

Will disable the lint rule for the first occurrence but not the second.

This doesn't seem addressable with gdlint: ignore either, as gdformat splits the push_warning call to three lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions