robotcode-analyze 0.97.0__tar.gz → 0.99.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/PKG-INFO +4 -4
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/pyproject.toml +3 -3
- robotcode_analyze-0.99.0/src/robotcode/analyze/__version__.py +1 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/cli.py +122 -7
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/code_analyzer.py +1 -1
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/config.py +10 -10
- robotcode_analyze-0.97.0/src/robotcode/analyze/__version__.py +0 -1
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/.gitignore +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/LICENSE.txt +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/README.md +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/__init__.py +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/diagnostics_context.py +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/hooks.py +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/language_provider.py +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/py.typed +0 -0
- {robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/robot_framework_language_provider.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: robotcode-analyze
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.99.0
|
|
4
4
|
Summary: RobotCode analyze plugin for Robot Framework
|
|
5
5
|
Project-URL: Homepage, https://robotcode.io
|
|
6
6
|
Project-URL: Donate, https://opencollective.com/robotcode
|
|
@@ -24,9 +24,9 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
24
24
|
Classifier: Topic :: Utilities
|
|
25
25
|
Classifier: Typing :: Typed
|
|
26
26
|
Requires-Python: >=3.8
|
|
27
|
-
Requires-Dist: robotcode-plugin==0.
|
|
28
|
-
Requires-Dist: robotcode-robot==0.
|
|
29
|
-
Requires-Dist: robotcode==0.
|
|
27
|
+
Requires-Dist: robotcode-plugin==0.99.0
|
|
28
|
+
Requires-Dist: robotcode-robot==0.99.0
|
|
29
|
+
Requires-Dist: robotcode==0.99.0
|
|
30
30
|
Requires-Dist: robotframework>=4.1.0
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
@@ -27,9 +27,9 @@ classifiers = [
|
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
29
|
"robotframework>=4.1.0",
|
|
30
|
-
"robotcode-plugin==0.
|
|
31
|
-
"robotcode-robot==0.
|
|
32
|
-
"robotcode==0.
|
|
30
|
+
"robotcode-plugin==0.99.0",
|
|
31
|
+
"robotcode-robot==0.99.0",
|
|
32
|
+
"robotcode==0.99.0",
|
|
33
33
|
]
|
|
34
34
|
dynamic = ["version"]
|
|
35
35
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.99.0"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
from enum import Flag
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from textwrap import indent
|
|
3
4
|
from typing import List, Optional, Set, Tuple
|
|
4
5
|
|
|
5
6
|
import click
|
|
6
7
|
|
|
7
|
-
from robotcode.analyze.config import AnalyzeConfig
|
|
8
8
|
from robotcode.core.lsp.types import Diagnostic, DiagnosticSeverity
|
|
9
9
|
from robotcode.core.text_document import TextDocument
|
|
10
10
|
from robotcode.core.uri import Uri
|
|
@@ -18,6 +18,7 @@ from robotcode.robot.config.utils import get_config_files
|
|
|
18
18
|
|
|
19
19
|
from .__version__ import __version__
|
|
20
20
|
from .code_analyzer import CodeAnalyzer, DocumentDiagnosticReport, FolderDiagnosticReport
|
|
21
|
+
from .config import AnalyzeConfig, ModifiersConfig
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
@click.group(
|
|
@@ -45,6 +46,14 @@ SEVERITY_COLORS = {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
class ReturnCode(Flag):
|
|
50
|
+
SUCCESS = 0
|
|
51
|
+
ERRORS = 1
|
|
52
|
+
WARNINGS = 2
|
|
53
|
+
INFOS = 4
|
|
54
|
+
HINTS = 8
|
|
55
|
+
|
|
56
|
+
|
|
48
57
|
class Statistic:
|
|
49
58
|
def __init__(self) -> None:
|
|
50
59
|
self.folders: Set[WorkspaceFolder] = set()
|
|
@@ -60,6 +69,18 @@ class Statistic:
|
|
|
60
69
|
f"Infos: {self.infos}, Hints: {self.hints}"
|
|
61
70
|
)
|
|
62
71
|
|
|
72
|
+
def calculate_return_code(self) -> ReturnCode:
|
|
73
|
+
return_code = ReturnCode.SUCCESS
|
|
74
|
+
if self.errors > 0:
|
|
75
|
+
return_code |= ReturnCode.ERRORS
|
|
76
|
+
if self.warnings > 0:
|
|
77
|
+
return_code |= ReturnCode.WARNINGS
|
|
78
|
+
if self.infos > 0:
|
|
79
|
+
return_code |= ReturnCode.INFOS
|
|
80
|
+
if self.hints > 0:
|
|
81
|
+
return_code |= ReturnCode.HINTS
|
|
82
|
+
return return_code
|
|
83
|
+
|
|
63
84
|
|
|
64
85
|
@analyze.command(
|
|
65
86
|
add_help_option=True,
|
|
@@ -105,22 +126,88 @@ class Statistic:
|
|
|
105
126
|
help="Additional locations where to search test libraries"
|
|
106
127
|
" and other extensions when they are imported. see `robot --pythonpath` option.",
|
|
107
128
|
)
|
|
129
|
+
@click.option(
|
|
130
|
+
"-mi",
|
|
131
|
+
"--modifiers-ignore",
|
|
132
|
+
metavar="CODE",
|
|
133
|
+
type=str,
|
|
134
|
+
multiple=True,
|
|
135
|
+
help="Specifies the diagnostics codes to ignore.",
|
|
136
|
+
)
|
|
137
|
+
@click.option(
|
|
138
|
+
"-me",
|
|
139
|
+
"--modifiers-error",
|
|
140
|
+
metavar="CODE",
|
|
141
|
+
type=str,
|
|
142
|
+
multiple=True,
|
|
143
|
+
help="Specifies the diagnostics codes to treat as errors.",
|
|
144
|
+
)
|
|
145
|
+
@click.option(
|
|
146
|
+
"-mw",
|
|
147
|
+
"--modifiers-warning",
|
|
148
|
+
metavar="CODE",
|
|
149
|
+
type=str,
|
|
150
|
+
multiple=True,
|
|
151
|
+
help="Specifies the diagnostics codes to treat as warning.",
|
|
152
|
+
)
|
|
153
|
+
@click.option(
|
|
154
|
+
"-mI",
|
|
155
|
+
"--modifiers-information",
|
|
156
|
+
metavar="CODE",
|
|
157
|
+
type=str,
|
|
158
|
+
multiple=True,
|
|
159
|
+
help="Specifies the diagnostics codes to treat as information.",
|
|
160
|
+
)
|
|
161
|
+
@click.option(
|
|
162
|
+
"-mh",
|
|
163
|
+
"--modifiers-hint",
|
|
164
|
+
metavar="CODE",
|
|
165
|
+
type=str,
|
|
166
|
+
multiple=True,
|
|
167
|
+
help="Specifies the diagnostics codes to treat as hint.",
|
|
168
|
+
)
|
|
108
169
|
@click.argument(
|
|
109
170
|
"paths", nargs=-1, type=click.Path(exists=True, dir_okay=True, file_okay=True, readable=True, path_type=Path)
|
|
110
171
|
)
|
|
111
172
|
@pass_application
|
|
112
173
|
def code(
|
|
113
174
|
app: Application,
|
|
114
|
-
filter: Tuple[str],
|
|
175
|
+
filter: Tuple[str, ...],
|
|
115
176
|
variable: Tuple[str, ...],
|
|
116
177
|
variablefile: Tuple[str, ...],
|
|
117
178
|
pythonpath: Tuple[str, ...],
|
|
179
|
+
modifiers_ignore: Tuple[str, ...],
|
|
180
|
+
modifiers_error: Tuple[str, ...],
|
|
181
|
+
modifiers_warning: Tuple[str, ...],
|
|
182
|
+
modifiers_information: Tuple[str, ...],
|
|
183
|
+
modifiers_hint: Tuple[str, ...],
|
|
118
184
|
paths: Tuple[Path],
|
|
119
185
|
) -> None:
|
|
120
186
|
"""\
|
|
121
|
-
Performs static code analysis to
|
|
122
|
-
|
|
123
|
-
|
|
187
|
+
Performs static code analysis to identify potential issues in the specified *PATHS*. The analysis detects syntax
|
|
188
|
+
errors, missing keywords or variables, missing arguments, and other problems.
|
|
189
|
+
|
|
190
|
+
- **PATHS**: Can be individual files or directories. If no *PATHS* are provided, the current directory is
|
|
191
|
+
analyzed by default.
|
|
192
|
+
|
|
193
|
+
The return code is a bitwise combination of the following values:
|
|
194
|
+
|
|
195
|
+
\b
|
|
196
|
+
- `0`: **SUCCESS** - No issues detected.
|
|
197
|
+
- `1`: **ERRORS** - Critical issues found.
|
|
198
|
+
- `2`: **WARNINGS** - Non-critical issues detected.
|
|
199
|
+
- `4`: **INFORMATIONS** - General information messages.
|
|
200
|
+
- `8`: **HINTS** - Suggestions or improvements.
|
|
201
|
+
|
|
202
|
+
\b
|
|
203
|
+
*Examples*:
|
|
204
|
+
```
|
|
205
|
+
robotcode analyze code
|
|
206
|
+
robotcode analyze code --filter **/*.robot
|
|
207
|
+
robotcode analyze code tests/acceptance/first.robot
|
|
208
|
+
robotcode analyze code -mi DuplicateKeyword tests/acceptance/first.robot
|
|
209
|
+
robotcode --format json analyze code
|
|
210
|
+
```
|
|
124
211
|
"""
|
|
125
212
|
|
|
126
213
|
config_files, root_folder, _ = get_config_files(
|
|
@@ -162,6 +249,34 @@ def code(
|
|
|
162
249
|
for vf in variablefile:
|
|
163
250
|
robot_profile.variable_files.append(vf)
|
|
164
251
|
|
|
252
|
+
if analyzer_config.modifiers is None:
|
|
253
|
+
analyzer_config.modifiers = ModifiersConfig()
|
|
254
|
+
|
|
255
|
+
if modifiers_ignore:
|
|
256
|
+
if analyzer_config.modifiers.ignore is None:
|
|
257
|
+
analyzer_config.modifiers.ignore = []
|
|
258
|
+
analyzer_config.modifiers.ignore.extend(modifiers_ignore)
|
|
259
|
+
|
|
260
|
+
if modifiers_error:
|
|
261
|
+
if analyzer_config.modifiers.error is None:
|
|
262
|
+
analyzer_config.modifiers.error = []
|
|
263
|
+
analyzer_config.modifiers.error.extend(modifiers_error)
|
|
264
|
+
|
|
265
|
+
if modifiers_warning:
|
|
266
|
+
if analyzer_config.modifiers.warning is None:
|
|
267
|
+
analyzer_config.modifiers.warning = []
|
|
268
|
+
analyzer_config.modifiers.warning.extend(modifiers_warning)
|
|
269
|
+
|
|
270
|
+
if modifiers_information:
|
|
271
|
+
if analyzer_config.modifiers.information is None:
|
|
272
|
+
analyzer_config.modifiers.information = []
|
|
273
|
+
analyzer_config.modifiers.information.extend(modifiers_information)
|
|
274
|
+
|
|
275
|
+
if modifiers_hint:
|
|
276
|
+
if analyzer_config.modifiers.hint is None:
|
|
277
|
+
analyzer_config.modifiers.hint = []
|
|
278
|
+
analyzer_config.modifiers.hint.extend(modifiers_hint)
|
|
279
|
+
|
|
165
280
|
statistics = Statistic()
|
|
166
281
|
for e in CodeAnalyzer(
|
|
167
282
|
app=app,
|
|
@@ -190,7 +305,7 @@ def code(
|
|
|
190
305
|
|
|
191
306
|
app.echo(statistics_str)
|
|
192
307
|
|
|
193
|
-
app.exit(statistics.
|
|
308
|
+
app.exit(statistics.calculate_return_code().value)
|
|
194
309
|
|
|
195
310
|
except (TypeError, ValueError) as e:
|
|
196
311
|
raise click.ClickException(str(e)) from e
|
|
@@ -223,7 +338,7 @@ def _print_diagnostics(
|
|
|
223
338
|
+ (f"{item.range.start.line + 1}:{item.range.start.character + 1}: " if print_range else " ")
|
|
224
339
|
)
|
|
225
340
|
if folder_path and folder_path != root_folder
|
|
226
|
-
else "
|
|
341
|
+
else ""
|
|
227
342
|
)
|
|
228
343
|
+ click.style(f"[{severity.name[0]}] {item.code}", fg=SEVERITY_COLORS[severity])
|
|
229
344
|
+ f": {indent(item.message, prefix=' ').strip()}",
|
{robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/code_analyzer.py
RENAMED
|
@@ -122,7 +122,7 @@ class CodeAnalyzer(DiagnosticsContext):
|
|
|
122
122
|
if item is None:
|
|
123
123
|
continue
|
|
124
124
|
elif isinstance(item, BaseException):
|
|
125
|
-
self.app.error(f"Error
|
|
125
|
+
self.app.error(f"Error collecting diagnostics for {document.uri.to_path()}: {item}")
|
|
126
126
|
else:
|
|
127
127
|
diagnostics.extend(item)
|
|
128
128
|
if diagnostics:
|
|
@@ -17,7 +17,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
17
17
|
|
|
18
18
|
ignore: Optional[List[str]] = field(
|
|
19
19
|
description="""\
|
|
20
|
-
Specifies the
|
|
20
|
+
Specifies the diagnostics codes to ignore.
|
|
21
21
|
|
|
22
22
|
Examples:
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
29
29
|
)
|
|
30
30
|
extend_ignore: Optional[List[str]] = field(
|
|
31
31
|
description="""
|
|
32
|
-
Extend the
|
|
32
|
+
Extend the diagnostics codes to ignore.
|
|
33
33
|
|
|
34
34
|
Examples:
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
41
41
|
)
|
|
42
42
|
error: Optional[List[str]] = field(
|
|
43
43
|
description="""
|
|
44
|
-
Specifies the
|
|
44
|
+
Specifies the diagnostics codes to treat as errors.
|
|
45
45
|
|
|
46
46
|
Examples:
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
53
53
|
)
|
|
54
54
|
extend_error: Optional[List[str]] = field(
|
|
55
55
|
description="""
|
|
56
|
-
Extend the
|
|
56
|
+
Extend the diagnostics codes to treat as errors.
|
|
57
57
|
|
|
58
58
|
Examples:
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
65
65
|
)
|
|
66
66
|
warning: Optional[List[str]] = field(
|
|
67
67
|
description="""
|
|
68
|
-
Specifies the
|
|
68
|
+
Specifies the diagnostics codes to treat as warning.
|
|
69
69
|
|
|
70
70
|
Examples:
|
|
71
71
|
|
|
@@ -77,7 +77,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
77
77
|
)
|
|
78
78
|
extend_warning: Optional[List[str]] = field(
|
|
79
79
|
description="""
|
|
80
|
-
Extend the
|
|
80
|
+
Extend the diagnostics codes to treat as warning.
|
|
81
81
|
|
|
82
82
|
Examples:
|
|
83
83
|
|
|
@@ -89,7 +89,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
89
89
|
)
|
|
90
90
|
information: Optional[List[str]] = field(
|
|
91
91
|
description="""
|
|
92
|
-
Specifies the
|
|
92
|
+
Specifies the diagnostics codes to treat as information.
|
|
93
93
|
|
|
94
94
|
Examples:
|
|
95
95
|
|
|
@@ -101,7 +101,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
101
101
|
)
|
|
102
102
|
extend_information: Optional[List[str]] = field(
|
|
103
103
|
description="""
|
|
104
|
-
Extend the
|
|
104
|
+
Extend the diagnostics codes to treat as information.
|
|
105
105
|
|
|
106
106
|
Examples:
|
|
107
107
|
|
|
@@ -113,7 +113,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
113
113
|
)
|
|
114
114
|
hint: Optional[List[str]] = field(
|
|
115
115
|
description="""
|
|
116
|
-
Specifies the
|
|
116
|
+
Specifies the diagnostics codes to treat as hint.
|
|
117
117
|
|
|
118
118
|
Examples:
|
|
119
119
|
|
|
@@ -125,7 +125,7 @@ class ModifiersConfig(BaseOptions):
|
|
|
125
125
|
)
|
|
126
126
|
extend_hint: Optional[List[str]] = field(
|
|
127
127
|
description="""
|
|
128
|
-
Extend the
|
|
128
|
+
Extend the diagnostics codes to treat as hint.
|
|
129
129
|
|
|
130
130
|
Examples:
|
|
131
131
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.97.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/diagnostics_context.py
RENAMED
|
File without changes
|
|
File without changes
|
{robotcode_analyze-0.97.0 → robotcode_analyze-0.99.0}/src/robotcode/analyze/language_provider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|