robotcode-analyze 0.98.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robotcode-analyze
3
- Version: 0.98.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.98.0
28
- Requires-Dist: robotcode-robot==0.98.0
29
- Requires-Dist: robotcode==0.98.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.98.0",
31
- "robotcode-robot==0.98.0",
32
- "robotcode==0.98.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,3 +1,4 @@
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
@@ -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,
@@ -151,7 +172,7 @@ class Statistic:
151
172
  @pass_application
152
173
  def code(
153
174
  app: Application,
154
- filter: Tuple[str],
175
+ filter: Tuple[str, ...],
155
176
  variable: Tuple[str, ...],
156
177
  variablefile: Tuple[str, ...],
157
178
  pythonpath: Tuple[str, ...],
@@ -163,12 +184,23 @@ def code(
163
184
  paths: Tuple[Path],
164
185
  ) -> None:
165
186
  """\
166
- Performs static code analysis to detect syntax errors, missing keywords or variables,
167
- missing arguments, and more on the given *PATHS*. *PATHS* can be files or directories.
168
- If no PATHS are given, the current directory is used.
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.
169
201
 
170
202
  \b
171
- Examples:
203
+ *Examples*:
172
204
  ```
173
205
  robotcode analyze code
174
206
  robotcode analyze code --filter **/*.robot
@@ -273,7 +305,7 @@ def code(
273
305
 
274
306
  app.echo(statistics_str)
275
307
 
276
- app.exit(statistics.errors)
308
+ app.exit(statistics.calculate_return_code().value)
277
309
 
278
310
  except (TypeError, ValueError) as e:
279
311
  raise click.ClickException(str(e)) from e
@@ -1 +0,0 @@
1
- __version__ = "0.98.0"