auto-coder 0.1.331__py3-none-any.whl → 0.1.333__py3-none-any.whl

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.

Potentially problematic release.


This version of auto-coder might be problematic. Click here for more details.

@@ -207,22 +207,59 @@ class ReactJSLinter(BaseLinter):
207
207
  Returns:
208
208
  str: The extracted JSON string, or the original text if no separator is found.
209
209
  """
210
- if "=============" in output_text:
211
- lines = output_text.split('\n')
212
- json_lines = []
213
- found_separator = False
214
-
215
- for line in lines:
216
- if line.startswith("============="):
217
- found_separator = True
218
- continue
219
- if found_separator:
220
- json_lines.append(line)
210
+ return output_text.split("=============")[-1]
211
+
212
+ def _convert_raw_lint_result_to_dict(self, raw_result: str,result: Dict[str, Any], project_path: str):
213
+ try:
214
+ output_text = raw_result
215
+ eslint_output = []
216
+ try:
217
+ eslint_output = json.loads(output_text)
218
+ except json.JSONDecodeError:
219
+ # Try to extract JSON from output if it contains separator
220
+ json_text = self._extract_json_from_output(output_text)
221
+ try:
222
+ eslint_output = json.loads(json_text)
223
+ except json.JSONDecodeError:
224
+ print(json_text[0:100],"...",json_text[-100:])
221
225
 
222
- if json_lines:
223
- return '\n'.join(json_lines)
224
-
225
- return output_text
226
+ # print(f"eslint_output: {json.dumps(eslint_output, indent=4,ensure_ascii=False)}")
227
+
228
+ # Count files analyzed (should be 1)
229
+ result['files_analyzed'] = len(eslint_output)
230
+
231
+ # Track overall counts
232
+ total_errors = 0
233
+ total_warnings = 0
234
+
235
+ # Process the file result
236
+ for file_result in eslint_output:
237
+ file_rel_path = os.path.relpath(
238
+ file_result['filePath'], project_path)
239
+
240
+ # Add error and warning counts
241
+ total_errors += file_result.get('errorCount', 0)
242
+ total_warnings += file_result.get('warningCount', 0)
243
+
244
+ # Process individual messages
245
+ for message in file_result.get('messages', []):
246
+ issue = {
247
+ 'file': file_rel_path,
248
+ 'line': message.get('line', 0),
249
+ 'column': message.get('column', 0),
250
+ 'severity': 'error' if message.get('severity', 1) == 2 else 'warning',
251
+ 'message': message.get('message', ''),
252
+ 'rule': message.get('ruleId', 'unknown')
253
+ }
254
+ result['issues'].append(issue)
255
+
256
+ result['error_count'] = total_errors
257
+ result['warning_count'] = total_warnings
258
+ result['success'] = True
259
+ except json.JSONDecodeError:
260
+ # Handle case where ESLint output is not valid JSON
261
+ result['error'] = "Failed to parse ESLint output"
262
+
226
263
 
227
264
  def lint_file(self, file_path: str, fix: bool = False, project_path: str = None) -> Dict[str, Any]:
228
265
  """
@@ -296,51 +333,7 @@ class ReactJSLinter(BaseLinter):
296
333
 
297
334
  # Parse ESLint output
298
335
  if process.stdout:
299
- try:
300
- output_text = process.stdout
301
- try:
302
- eslint_output = json.loads(output_text)
303
- except json.JSONDecodeError:
304
- # Try to extract JSON from output if it contains separator
305
- json_text = self._extract_json_from_output(output_text)
306
- eslint_output = json.loads(json_text)
307
-
308
- # print(f"eslint_output: {json.dumps(eslint_output, indent=4,ensure_ascii=False)}")
309
-
310
- # Count files analyzed (should be 1)
311
- result['files_analyzed'] = len(eslint_output)
312
-
313
- # Track overall counts
314
- total_errors = 0
315
- total_warnings = 0
316
-
317
- # Process the file result
318
- for file_result in eslint_output:
319
- file_rel_path = os.path.relpath(
320
- file_result['filePath'], project_path)
321
-
322
- # Add error and warning counts
323
- total_errors += file_result.get('errorCount', 0)
324
- total_warnings += file_result.get('warningCount', 0)
325
-
326
- # Process individual messages
327
- for message in file_result.get('messages', []):
328
- issue = {
329
- 'file': file_rel_path,
330
- 'line': message.get('line', 0),
331
- 'column': message.get('column', 0),
332
- 'severity': 'error' if message.get('severity', 1) == 2 else 'warning',
333
- 'message': message.get('message', ''),
334
- 'rule': message.get('ruleId', 'unknown')
335
- }
336
- result['issues'].append(issue)
337
-
338
- result['error_count'] = total_errors
339
- result['warning_count'] = total_warnings
340
- result['success'] = True
341
- except json.JSONDecodeError:
342
- # Handle case where ESLint output is not valid JSON
343
- result['error'] = "Failed to parse ESLint output"
336
+ self._convert_raw_lint_result_to_dict(process.stdout, result, project_path)
344
337
  else:
345
338
  # Handle case where ESLint didn't produce any output
346
339
  stderr = process.stderr.strip()
@@ -577,4 +570,5 @@ def format_lint_result(lint_result: Dict[str, Any]) -> str:
577
570
  str: A formatted string representation of the lint results.
578
571
  """
579
572
  linter = ReactJSLinter()
580
- return linter.format_lint_result(lint_result)
573
+ return linter.format_lint_result(lint_result)
574
+
@@ -16,6 +16,7 @@ from autocoder.linters.models import (
16
16
  IssuePosition,
17
17
  IssueSeverity
18
18
  )
19
+ from loguru import logger as global_logger
19
20
 
20
21
  class ShadowLinter:
21
22
  """
@@ -32,6 +33,7 @@ class ShadowLinter:
32
33
  """
33
34
  self.shadow_manager = shadow_manager
34
35
  self.verbose = verbose
36
+ self.logger = global_logger.bind(name="ShadowLinter")
35
37
 
36
38
  def lint_shadow_file(self, shadow_path: str, fix: bool = False) -> FileLintResult:
37
39
  """
@@ -117,8 +119,10 @@ class ShadowLinter:
117
119
 
118
120
  # 处理每个影子文件
119
121
  for shadow_path in shadow_files:
122
+ self.logger.info(f"正在检查文件: {shadow_path}")
120
123
  try:
121
124
  file_result = self.lint_shadow_file(shadow_path, fix=fix)
125
+ self.logger.info(f"检查完成: {shadow_path}")
122
126
  # lint_shadow_file现在总是返回有效的FileLintResult,不再需要检查None
123
127
  project_path = self.shadow_manager.from_shadow_path(shadow_path)
124
128
 
@@ -285,7 +285,7 @@ class ShadowManager:
285
285
  # 删除链接项目目录中的所有内容
286
286
  for item in os.listdir(self.link_projects_dir):
287
287
  item_path = os.path.join(self.link_projects_dir, item)
288
- if os.path.isfile(item_path):
288
+ if os.path.isfile(item_path) or os.path.islink(item_path):
289
289
  os.unlink(item_path)
290
290
  elif os.path.isdir(item_path):
291
291
  shutil.rmtree(item_path)
@@ -127,9 +127,9 @@ class EnhancedFileAnalyzer:
127
127
  return self._basic_analysis(extensions)
128
128
 
129
129
  def _collect_extensions(self) -> Set[str]:
130
- """带过滤的文件后缀收集"""
130
+ """带过滤的文件后缀收集,支持软链接目录和文件"""
131
131
  extensions = set()
132
- for root, dirs, files in os.walk(self.directory):
132
+ for root, dirs, files in os.walk(self.directory, followlinks=True):
133
133
  dirs[:] = [d for d in dirs if not self.file_filter.should_ignore(d, True)]
134
134
  for file in files:
135
135
  if self.file_filter.should_ignore(file, False):
autocoder/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.331"
1
+ __version__ = "0.1.333"