Initial upload: ErrorFix CLI with rule engine and pattern matching
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-01 03:56:28 +00:00
parent c3d5241e29
commit ca81b0c8dc

131
rules/python/errors.yaml Normal file
View File

@@ -0,0 +1,131 @@
- id: python-syntax-error-indentation
name: "Python Syntax Error - Indentation"
pattern: "IndentationError: unindent does not match any outer indentation level"
fix: "Check and fix the indentation of your code. Ensure consistent use of spaces or tabs."
description: "Indentation does not match any outer indentation level"
severity: error
language: python
tool: python
tags: [syntax, indentation]
priority: 10
- id: python-syntax-error-tab
name: "Python Syntax Error - Tab/Space Mix"
pattern: "IndentationError: inconsistent use of tabs and spaces in indentation"
fix: "Use either tabs or spaces consistently throughout your code. Configure your editor to replace tabs with spaces."
description: "Inconsistent use of tabs and spaces in indentation"
severity: error
language: python
tool: python
tags: [syntax, indentation]
priority: 10
- id: python-name-error
name: "Python Name Error"
pattern: "NameError: name '(?P<name>[a-zA-Z_][a-zA-Z0-9_]*)' is not defined"
fix: "Define '{name}' before using it, or check for typos in the variable/function name."
description: "A name is referenced that has not been defined"
severity: error
language: python
tool: python
tags: [name-error, undefined]
priority: 9
- id: python-import-error
name: "Python Import Error"
pattern: "ModuleNotFoundError: No module named '(?P<module>[a-zA-Z0-9_.]+)'"
fix: "Install the module '{module}' using pip: pip install {module}"
description: "A module could not be found"
severity: error
language: python
tool: python
tags: [import, module]
priority: 9
- id: python-attribute-error
name: "Python Attribute Error"
pattern: "AttributeError: '(?P<object>[a-zA-Z_][a-zA-Z0-9_]*)' object has no attribute '(?P<attribute>[a-zA-Z_][a-zA-Z0-9_]*)'"
fix: "Check if '{attribute}' exists on the '{object}' type. You may need to import the correct module or check for typos."
description: "An object does not have the specified attribute"
severity: error
language: python
tool: python
tags: [attribute, object]
priority: 9
- id: python-type-error
name: "Python Type Error"
pattern: "TypeError: (?P<message>.*)"
fix: "Check the types of your operands. {message}"
description: "An operation was performed on incompatible types"
severity: error
language: python
tool: python
tags: [type, type-error]
priority: 8
- id: python-value-error
name: "Python Value Error"
pattern: "ValueError: (?P<message>.*)"
fix: "Check the value provided. {message}"
description: "A value had the appropriate type but an inappropriate value"
severity: error
language: python
tool: python
tags: [value, validation]
priority: 8
- id: python-index-error
name: "Python Index Error"
pattern: "IndexError: list index out of range"
fix: "Check the index value. Ensure it's within the bounds of the list (0 to len(list) - 1)."
description: "An index is out of range for a list"
severity: error
language: python
tool: python
tags: [index, list, bounds]
priority: 8
- id: python-key-error
name: "Python Key Error"
pattern: "KeyError: '(?P<key>[^']+)'"
fix: "The key '{key}' does not exist in the dictionary. Use dict.get() or check if the key exists first."
description: "A dictionary key was not found"
severity: error
language: python
tool: python
tags: [key, dictionary]
priority: 8
- id: python-zero-division
name: "Python Zero Division Error"
pattern: "ZeroDivisionError: division by zero"
fix: "Check for zero before dividing. Add a check: if divisor != 0: result = dividend / divisor"
description: "Attempted to divide by zero"
severity: error
language: python
tool: python
tags: [division, zero]
priority: 8
- id: python-syntax-error-eof
name: "Python Syntax Error - Unexpected EOF"
pattern: "SyntaxError: unexpected EOF while parsing"
fix: "Check for missing closing parentheses, brackets, or braces. Ensure all code blocks are properly closed."
description: "Unexpected end of file while parsing"
severity: error
language: python
tool: python
tags: [syntax, eof]
priority: 10
- id: python-syntax-error-invalid
name: "Python Syntax Error - Invalid Syntax"
pattern: "SyntaxError: invalid syntax"
fix: "Review the line for syntax errors. Check for missing colons, parentheses, or incorrect keyword usage."
description: "Invalid Python syntax"
severity: error
language: python
tool: python
tags: [syntax, invalid]
priority: 10