Skip to content

Commit c5f766f

Browse files
committed
feat(analyzer): add error codes VariableNotReplaced and EnvironmentVariableNotReplaced for variables not found/replaced in documentation, tags, and metadata
1 parent 8c7212d commit c5f766f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

packages/robot/src/robotcode/robot/diagnostics/errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
@final
77
class Error:
88
VARIABLE_NOT_FOUND = "VariableNotFound"
9+
VARIABLE_NOT_REPLACED = "VariableNotReplaced"
910
ENVIRONMENT_VARIABLE_NOT_FOUND = "EnvironmentVariableNotFound"
11+
ENVIRONMENT_VARIABLE_NOT_REPLACED = "EnvironmentVariableNotReplaced"
1012
KEYWORD_NOT_FOUND = "KeywordNotFound"
1113
LIBRARY_CONTAINS_NO_KEYWORDS = "LibraryContainsNoKeywords"
1214
POSSIBLE_CIRCULAR_IMPORT = "PossibleCircularImport"

packages/robot/src/robotcode/robot/diagnostics/namespace_analyzer.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,13 @@ def _handle_find_variable_result(
480480
if var.type == VariableDefinitionType.VARIABLE_NOT_FOUND:
481481
self._append_diagnostics(
482482
range=range_from_token(var_token),
483-
message=f"Variable '{var.name}' not found.",
483+
message=(
484+
f"Variable '{var.name}' not replaced."
485+
if severity == DiagnosticSeverity.HINT
486+
else f"Variable '{var.name}' not found."
487+
),
484488
severity=severity,
485-
code=Error.VARIABLE_NOT_FOUND,
489+
code=Error.VARIABLE_NOT_REPLACED if severity == DiagnosticSeverity.HINT else Error.VARIABLE_NOT_FOUND,
486490
)
487491
else:
488492
if (
@@ -493,9 +497,17 @@ def _handle_find_variable_result(
493497
if os.environ.get(env_name, None) is None:
494498
self._append_diagnostics(
495499
range=range_from_token(var_token),
496-
message=f"Environment variable '{var.name}' not found.",
500+
message=(
501+
f"Environment variable '{var.name}' not replaced."
502+
if severity == DiagnosticSeverity.HINT
503+
else f"Environment variable '{var.name}' not found."
504+
),
497505
severity=severity,
498-
code=Error.ENVIRONMENT_VARIABLE_NOT_FOUND,
506+
code=(
507+
Error.ENVIRONMENT_VARIABLE_NOT_REPLACED
508+
if severity == DiagnosticSeverity.HINT
509+
else Error.ENVIRONMENT_VARIABLE_NOT_FOUND
510+
),
499511
)
500512

501513
if var.type == VariableDefinitionType.ENVIRONMENT_VARIABLE:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ mypy_path = [
262262
"packages/robot/src",
263263
"packages/runner/src",
264264
"packages/analyze/src",
265+
"packages/repl/src",
266+
"packages/repl_server/src",
265267
]
266268
# allow_untyped_calls = true
267269

0 commit comments

Comments
 (0)