Skip to content

Commit

Permalink
Change some files to match the rest of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jun 18, 2024
1 parent 9d770a2 commit 97cf1c5
Show file tree
Hide file tree
Showing 29 changed files with 55 additions and 58 deletions.
9 changes: 3 additions & 6 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ The following **208** rules are applied by this linter:

| Rule ID | Title | Description | Config<br />(Name:Type:Default) | Source | Tags |
| -------- | ----- | ----------- | ---------- | ------ | ---- |
| [E0000<a name="E0000"></a>](../src/cfnlint/rules/ParseError.py) | Parsing error found when parsing the template | Checks for JSON/YAML formatting errors in your template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base` |
| [E0001<a name="E0001"></a>](../src/cfnlint/rules/TransformError.py) | Error found when transforming the template | Errors found when performing transformation on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`transform` |
| [E0002<a name="E0002"></a>](../src/cfnlint/rules/RuleError.py) | Error processing rule on the template | Errors found when processing a rule on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`rule` |
| [E0000<a name="E0000"></a>](../src/cfnlint/rules/ParseError.py) | Parsing error found when parsing the template | Checks for JSON/YAML formatting errors in your template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base` |
| [E0001<a name="E0001"></a>](../src/cfnlint/rules/TransformError.py) | Error found when transforming the template | Errors found when performing transformation on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`transform` |
| [E0002<a name="E0002"></a>](../src/cfnlint/rules/RuleError.py) | Error processing rule on the template | Errors found when processing a rule on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`rule` |
| [E0000<a name="E0000"></a>](../src/cfnlint/rules/errors/parse.py) | Parsing error found when parsing the template | Checks for JSON/YAML formatting errors in your template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base` |
| [E0001<a name="E0001"></a>](../src/cfnlint/rules/errors/transform.py) | Error found when transforming the template | Errors found when performing transformation on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`transform` |
| [E0002<a name="E0002"></a>](../src/cfnlint/rules/errors/rule.py) | Error processing rule on the template | Errors found when processing a rule on the template | | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base`,`rule` |
| [E1001<a name="E1001"></a>](../src/cfnlint/rules/jsonschema/JsonSchema.py) | Basic CloudFormation Template Configuration | Making sure the basic CloudFormation template components are properly configured | sections:string: | [Source](https://github.com/aws-cloudformation/cfn-python-lint) | `base` |
| [E1002<a name="E1002"></a>](../src/cfnlint/rules/templates/LimitSize.py) | Validate if a template size is too large | Check the size of the template is less than the upper limit | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) | `limits` |
| [E1003<a name="E1003"></a>](../src/cfnlint/rules/templates/LimitDescription.py) | Validate the max size of a description | Check if the size of the template description is less than the upper limit | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) | `description`,`limits` |
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import TYPE_CHECKING, Any, List, Protocol, Union

if TYPE_CHECKING:
from cfnlint.rules._Rule import RuleMatch
from cfnlint.rules import RuleMatch

RuleMatches = List["RuleMatch"]
Path = List[Union[str, int]]
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/decode/cfn_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from cfnlint.decode.mark import Mark
from cfnlint.decode.node import dict_node, list_node, str_node
from cfnlint.match import Match
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/decode/cfn_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from cfnlint.decode.node import dict_node, list_node, str_node
from cfnlint.rules import Match
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

try:
from yaml._yaml import CParser as Parser # pylint: disable=ungrouped-imports,
Expand Down
8 changes: 4 additions & 4 deletions src/cfnlint/decode/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _decode(

if not isinstance(template, dict) and not matches:
# pylint: disable=import-outside-toplevel
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

# Template isn't a dict which means nearly nothing will work
matches = [
Expand All @@ -151,7 +151,7 @@ def _decode(
def create_match_yaml_parser_error(parser_error, filename):
"""Create a Match for a parser error"""
# pylint: disable=import-outside-toplevel
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

lineno = parser_error.problem_mark.line + 1
colno = parser_error.problem_mark.column + 1
Expand All @@ -168,7 +168,7 @@ def create_match_yaml_parser_error(parser_error, filename):
def create_match_file_error(filename, msg):
"""Create a Match for a parser error"""
# pylint: disable=import-outside-toplevel
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

return Match.create(
filename=filename,
Expand All @@ -180,7 +180,7 @@ def create_match_file_error(filename, msg):
def create_match_json_parser_error(parser_error, filename):
"""Create a Match for a parser error"""
# pylint: disable=import-outside-toplevel
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.errors import ParseError

lineno = parser_error.lineno
colno = parser_error.colno
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/formatters/Formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter


class Formatter(BaseFormatter):
Expand Down
16 changes: 8 additions & 8 deletions src/cfnlint/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.Formatter import Formatter
from cfnlint.formatters.JsonFormatter import JsonFormatter
from cfnlint.formatters.JUnitFormatter import JUnitFormatter
from cfnlint.formatters.ParseableFormat import ParseableFormatter
from cfnlint.formatters.PrettyFormatter import PrettyFormatter
from cfnlint.formatters.QuitFormatter import QuietFormatter
from cfnlint.formatters.SARIFFormatter import SARIFFormatter
from cfnlint.formatters.base import BaseFormatter
from cfnlint.formatters.formatter import Formatter
from cfnlint.formatters.json import JsonFormatter
from cfnlint.formatters.junit import JUnitFormatter
from cfnlint.formatters.parseable import ParseableFormatter
from cfnlint.formatters.pretty import PrettyFormatter
from cfnlint.formatters.quit import QuietFormatter
from cfnlint.formatters.sarif import SARIFFormatter
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import json

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter
from cfnlint.rules import Match


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter


class JUnitFormatter(BaseFormatter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import regex as re

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter


class ParseableFormatter(BaseFormatter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import operator

from cfnlint.formatters._utils import color, colored
from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter


class PrettyFormatter(BaseFormatter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter


class QuietFormatter(BaseFormatter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing import List

from cfnlint.formatters.BaseFormatter import BaseFormatter
from cfnlint.formatters.base import BaseFormatter
from cfnlint.match import Match
from cfnlint.rules import Rules
from cfnlint.version import __version__
Expand Down
4 changes: 2 additions & 2 deletions src/cfnlint/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def converter(o): # pylint: disable=R1710
def create_rules(
mod,
name="CloudFormationLintRule",
modules=("cfnlint", "cfnlint.rules", "cfnlint.rules._Rule"),
modules=("cfnlint", "cfnlint.rules", "cfnlint.rules._rule"),
):
"""Create and return an instance of each CloudFormationLintRule subclass
from the given module."""
Expand Down Expand Up @@ -601,7 +601,7 @@ def import_filename(pluginname, root):
def load_plugins(
directory,
name="CloudFormationLintRule",
modules=("cfnlint", "cfnlint.rules", "cfnlint.rules._Rule"),
modules=("cfnlint", "cfnlint.rules", "cfnlint.rules._rule"),
):
"""Load plugins"""
result = []
Expand Down
6 changes: 1 addition & 5 deletions src/cfnlint/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ def update_documentation(rules):
'| [{0}<a name="{0}"></a>]({6}) | {1} | {2} | {3} | [Source]({4}) | {5} |\n'
)

for rule in [
cfnlint.rules.ParseError.ParseError(),
cfnlint.rules.TransformError.TransformError(),
cfnlint.rules.RuleError.RuleError(),
] + sorted_rules:
for rule in sorted_rules:
rule_source_code_file = (
"../"
+ subprocess.check_output(
Expand Down
4 changes: 2 additions & 2 deletions src/cfnlint/rules/_Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import cfnlint.helpers
import cfnlint.rules.custom
from cfnlint.exceptions import DuplicateRuleError
from cfnlint.rules._Rule import CloudFormationLintRule, Match
from cfnlint.rules.RuleError import RuleError
from cfnlint.rules._rule import CloudFormationLintRule, Match
from cfnlint.rules.errors import RuleError
from cfnlint.template import Template

if TYPE_CHECKING:
Expand Down
4 changes: 2 additions & 2 deletions src/cfnlint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.rules._Rule import CloudFormationLintRule, Match, RuleMatch
from cfnlint.rules._Rules import Rules, RulesCollection
from cfnlint.rules._rule import CloudFormationLintRule, Match, RuleMatch
from cfnlint.rules._rules import Rules, RulesCollection
from cfnlint.rules.jsonschema import (
CfnLintJsonSchema,
CfnLintJsonSchemaRegional,
Expand Down
8 changes: 8 additions & 0 deletions src/cfnlint/rules/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""

from cfnlint.rules.errors.parse import ParseError
from cfnlint.rules.errors.rule import RuleError
from cfnlint.rules.errors.transform import TransformError
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.rules._Rule import CloudFormationLintRule
from cfnlint.rules._rule import CloudFormationLintRule


class ParseError(CloudFormationLintRule):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.rules._Rule import CloudFormationLintRule
from cfnlint.rules._rule import CloudFormationLintRule


class RuleError(CloudFormationLintRule):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from cfnlint.rules._Rule import CloudFormationLintRule
from cfnlint.rules._rule import CloudFormationLintRule


class TransformError(CloudFormationLintRule):
Expand Down
3 changes: 1 addition & 2 deletions src/cfnlint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from cfnlint.config import ConfigMixIn
from cfnlint.decode.decode import decode
from cfnlint.rules import Match, Rules
from cfnlint.rules.ParseError import ParseError
from cfnlint.rules.TransformError import TransformError
from cfnlint.rules.errors import ParseError, TransformError
from cfnlint.schema import PROVIDER_SCHEMA_MANAGER
from cfnlint.template.template import Template

Expand Down
8 changes: 2 additions & 6 deletions src/cfnlint/template/transforms/_language_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def language_extension(cfn: Any) -> TransformResult:
LOGGER.debug(e, exc_info=True)
# pylint: disable=import-outside-toplevel
from cfnlint.match import Match # pylint: disable=cyclic-import
from cfnlint.rules.TransformError import ( # pylint: disable=cyclic-import
TransformError,
)
from cfnlint.rules.errors import TransformError # pylint: disable=cyclic-import

message = "Error transforming template: {0}"
if hasattr(e.key, "start_mark"):
Expand Down Expand Up @@ -87,9 +85,7 @@ def language_extension(cfn: Any) -> TransformResult:
LOGGER.debug(e, exc_info=True)
# pylint: disable=import-outside-toplevel
from cfnlint.match import Match # pylint: disable=cyclic-import
from cfnlint.rules.TransformError import ( # pylint: disable=cyclic-import
TransformError,
)
from cfnlint.rules.errors import TransformError # pylint: disable=cyclic-import

message = "Error transforming template: {0}"
return [
Expand Down
4 changes: 2 additions & 2 deletions src/cfnlint/template/transforms/_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def transform_template(self):
except InvalidDocumentException as e:
# pylint: disable=import-outside-toplevel
from cfnlint.match import Match # pylint: disable=cyclic-import
from cfnlint.rules.TransformError import ( # pylint: disable=cyclic-import
from cfnlint.rules.errors import ( # pylint: disable=cyclic-import
TransformError,
)

Expand All @@ -177,7 +177,7 @@ def transform_template(self):
except Exception as e: # pylint: disable=W0703
# pylint: disable=import-outside-toplevel
from cfnlint.match import Match # pylint: disable=cyclic-import
from cfnlint.rules.TransformError import ( # pylint: disable=cyclic-import
from cfnlint.rules.errors import ( # pylint: disable=cyclic-import
TransformError,
)

Expand Down
7 changes: 4 additions & 3 deletions test/unit/module/maintenance/test_update_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,23 @@ def test_update_docs(self):
),
call(
'| [E0000<a name="E0000"></a>]'
"(../src/cfnlint/rules/ParseError.py) |"
"(../src/cfnlint/rules/errors/parse.py) |"
" Parsing error found when parsing the template | Checks for"
" JSON/YAML formatting errors in your template | |"
" [Source](https://github.com/aws-cloudformation/cfn-python-lint) |"
" `base` |\n"
),
call(
'| [E0001<a name="E0001"></a>]'
"(../src/cfnlint/rules/TransformError.py) |"
"(../src/cfnlint/rules/errors/transform.py) |"
" Error found when transforming the template | Errors found when"
" performing transformation on the template | |"
" [Source](https://github.com/aws-cloudformation/cfn-python-lint) |"
" `base`,`transform` |\n"
),
call(
'| [E0002<a name="E0002"></a>](../src/cfnlint/rules/RuleError.py) |'
'| [E0002<a name="E0002"></a>]'
"(../src/cfnlint/rules/errors/rule.py) |"
" Error processing rule on the template | Errors found when"
" processing a rule on the template | |"
" [Source](https://github.com/aws-cloudformation/cfn-python-lint) |"
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/rule/test_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any

from cfnlint.rules import CloudFormationLintRule, Match, RuleMatch
from cfnlint.rules._Rule import matching
from cfnlint.rules._rule import matching


class rule(CloudFormationLintRule):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/rule/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cfnlint.decode.node import dict_node
from cfnlint.exceptions import DuplicateRuleError
from cfnlint.rules import CloudFormationLintRule, Match, RuleMatch, Rules
from cfnlint.rules._Rules import RuleError
from cfnlint.rules.errors import RuleError


class Rule(CloudFormationLintRule):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/test_rules_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from cfnlint.exceptions import DuplicateRuleError
from cfnlint.match import Match
from cfnlint.rules import CloudFormationLintRule, RulesCollection
from cfnlint.rules.RuleError import RuleError
from cfnlint.rules.errors import RuleError
from cfnlint.template.template import Template


Expand Down

0 comments on commit 97cf1c5

Please sign in to comment.