robotcode-analyze 0.97.0__tar.gz → 0.98.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.97.0
3
+ Version: 0.98.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.97.0
28
- Requires-Dist: robotcode-robot==0.97.0
29
- Requires-Dist: robotcode==0.97.0
27
+ Requires-Dist: robotcode-plugin==0.98.0
28
+ Requires-Dist: robotcode-robot==0.98.0
29
+ Requires-Dist: robotcode==0.98.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.97.0",
31
- "robotcode-robot==0.97.0",
32
- "robotcode==0.97.0",
30
+ "robotcode-plugin==0.98.0",
31
+ "robotcode-robot==0.98.0",
32
+ "robotcode==0.98.0",
33
33
  ]
34
34
  dynamic = ["version"]
35
35
 
@@ -0,0 +1 @@
1
+ __version__ = "0.98.0"
@@ -4,7 +4,6 @@ from typing import List, Optional, Set, Tuple
4
4
 
5
5
  import click
6
6
 
7
- from robotcode.analyze.config import AnalyzeConfig
8
7
  from robotcode.core.lsp.types import Diagnostic, DiagnosticSeverity
9
8
  from robotcode.core.text_document import TextDocument
10
9
  from robotcode.core.uri import Uri
@@ -18,6 +17,7 @@ from robotcode.robot.config.utils import get_config_files
18
17
 
19
18
  from .__version__ import __version__
20
19
  from .code_analyzer import CodeAnalyzer, DocumentDiagnosticReport, FolderDiagnosticReport
20
+ from .config import AnalyzeConfig, ModifiersConfig
21
21
 
22
22
 
23
23
  @click.group(
@@ -105,6 +105,46 @@ class Statistic:
105
105
  help="Additional locations where to search test libraries"
106
106
  " and other extensions when they are imported. see `robot --pythonpath` option.",
107
107
  )
108
+ @click.option(
109
+ "-mi",
110
+ "--modifiers-ignore",
111
+ metavar="CODE",
112
+ type=str,
113
+ multiple=True,
114
+ help="Specifies the diagnostics codes to ignore.",
115
+ )
116
+ @click.option(
117
+ "-me",
118
+ "--modifiers-error",
119
+ metavar="CODE",
120
+ type=str,
121
+ multiple=True,
122
+ help="Specifies the diagnostics codes to treat as errors.",
123
+ )
124
+ @click.option(
125
+ "-mw",
126
+ "--modifiers-warning",
127
+ metavar="CODE",
128
+ type=str,
129
+ multiple=True,
130
+ help="Specifies the diagnostics codes to treat as warning.",
131
+ )
132
+ @click.option(
133
+ "-mI",
134
+ "--modifiers-information",
135
+ metavar="CODE",
136
+ type=str,
137
+ multiple=True,
138
+ help="Specifies the diagnostics codes to treat as information.",
139
+ )
140
+ @click.option(
141
+ "-mh",
142
+ "--modifiers-hint",
143
+ metavar="CODE",
144
+ type=str,
145
+ multiple=True,
146
+ help="Specifies the diagnostics codes to treat as hint.",
147
+ )
108
148
  @click.argument(
109
149
  "paths", nargs=-1, type=click.Path(exists=True, dir_okay=True, file_okay=True, readable=True, path_type=Path)
110
150
  )
@@ -115,12 +155,27 @@ def code(
115
155
  variable: Tuple[str, ...],
116
156
  variablefile: Tuple[str, ...],
117
157
  pythonpath: Tuple[str, ...],
158
+ modifiers_ignore: Tuple[str, ...],
159
+ modifiers_error: Tuple[str, ...],
160
+ modifiers_warning: Tuple[str, ...],
161
+ modifiers_information: Tuple[str, ...],
162
+ modifiers_hint: Tuple[str, ...],
118
163
  paths: Tuple[Path],
119
164
  ) -> None:
120
165
  """\
121
166
  Performs static code analysis to detect syntax errors, missing keywords or variables,
122
167
  missing arguments, and more on the given *PATHS*. *PATHS* can be files or directories.
123
168
  If no PATHS are given, the current directory is used.
169
+
170
+ \b
171
+ Examples:
172
+ ```
173
+ robotcode analyze code
174
+ robotcode analyze code --filter **/*.robot
175
+ robotcode analyze code tests/acceptance/first.robot
176
+ robotcode analyze code -mi DuplicateKeyword tests/acceptance/first.robot
177
+ robotcode --format json analyze code
178
+ ```
124
179
  """
125
180
 
126
181
  config_files, root_folder, _ = get_config_files(
@@ -162,6 +217,34 @@ def code(
162
217
  for vf in variablefile:
163
218
  robot_profile.variable_files.append(vf)
164
219
 
220
+ if analyzer_config.modifiers is None:
221
+ analyzer_config.modifiers = ModifiersConfig()
222
+
223
+ if modifiers_ignore:
224
+ if analyzer_config.modifiers.ignore is None:
225
+ analyzer_config.modifiers.ignore = []
226
+ analyzer_config.modifiers.ignore.extend(modifiers_ignore)
227
+
228
+ if modifiers_error:
229
+ if analyzer_config.modifiers.error is None:
230
+ analyzer_config.modifiers.error = []
231
+ analyzer_config.modifiers.error.extend(modifiers_error)
232
+
233
+ if modifiers_warning:
234
+ if analyzer_config.modifiers.warning is None:
235
+ analyzer_config.modifiers.warning = []
236
+ analyzer_config.modifiers.warning.extend(modifiers_warning)
237
+
238
+ if modifiers_information:
239
+ if analyzer_config.modifiers.information is None:
240
+ analyzer_config.modifiers.information = []
241
+ analyzer_config.modifiers.information.extend(modifiers_information)
242
+
243
+ if modifiers_hint:
244
+ if analyzer_config.modifiers.hint is None:
245
+ analyzer_config.modifiers.hint = []
246
+ analyzer_config.modifiers.hint.extend(modifiers_hint)
247
+
165
248
  statistics = Statistic()
166
249
  for e in CodeAnalyzer(
167
250
  app=app,
@@ -223,7 +306,7 @@ def _print_diagnostics(
223
306
  + (f"{item.range.start.line + 1}:{item.range.start.character + 1}: " if print_range else " ")
224
307
  )
225
308
  if folder_path and folder_path != root_folder
226
- else " "
309
+ else ""
227
310
  )
228
311
  + click.style(f"[{severity.name[0]}] {item.code}", fg=SEVERITY_COLORS[severity])
229
312
  + f": {indent(item.message, prefix=' ').strip()}",
@@ -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 analyzing {document.uri.to_path()}: {item}")
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 error codes to ignore.
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 error codes to ignore.
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 error codes to treat as errors.
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 error codes to treat as errors.
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 error codes to treat as warning.
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 error codes to treat as warnings.
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 error codes to treat as information.
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 error codes to treat as information.
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 error codes to treat as hint.
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 error codes to treat as hint.
128
+ Extend the diagnostics codes to treat as hint.
129
129
 
130
130
  Examples:
131
131
 
@@ -1 +0,0 @@
1
- __version__ = "0.97.0"