Repository: aws-cloudformation/cfn-lint

Issue:
Cannot list all the rules
### CloudFormation Lint Version

0.70.0

### What operating system are you using?

Windows

### Describe the bug

`cfn-lint --list-rules` throws below Error.(username is masked.)

```
Traceback (most recent call last):
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\Scripts\cfn-lint.exe\__main__.py", line 7, in <module>
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\site-packages\cfnlint\__main__.py", line 38, in main
    (args, filenames, formatter) = cfnlint.core.get_args_filenames(sys.argv[1:])
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\site-packages\cfnlint\core.py", line 235, in get_args_filenames
    print(rules)
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\site-packages\cfnlint\rules\__init__.py", line 306, in __repr__
    [rule.verbose() for rule in sorted(self.rules, key=lambda x: x.id)]
  File "C:\Users\${username}\AppData\Local\Programs\Python\Python39\lib\site-packages\cfnlint\rules\__init__.py", line 306, in <lambda>
    [rule.verbose() for rule in sorted(self.rules, key=lambda x: x.id)]
AttributeError: 'str' object has no attribute 'id'
```


### Expected behavior

show list all the rules.

### Reproduction template

This is not bug of linting.


Discussion:

Resolving patch:
diff --git a/src/cfnlint/rules/__init__.py b/src/cfnlint/rules/__init__.py
--- a/src/cfnlint/rules/__init__.py
+++ b/src/cfnlint/rules/__init__.py
@@ -302,9 +302,7 @@ def extend(self, more):
             self.register(rule)
 
     def __repr__(self):
-        return '\n'.join(
-            [rule.verbose() for rule in sorted(self.rules, key=lambda x: x.id)]
-        )
+        return '\n'.join([self.rules[id].verbose() for id in sorted(self.rules)])
 
     def is_rule_enabled(self, rule: CloudFormationLintRule):
         """Checks if an individual rule is valid"""


Test patch:
diff --git a/test/unit/module/test_rules_collections.py b/test/unit/module/test_rules_collections.py
--- a/test/unit/module/test_rules_collections.py
+++ b/test/unit/module/test_rules_collections.py
@@ -2,6 +2,7 @@
 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 SPDX-License-Identifier: MIT-0
 """
+import re
 from cfnlint.exceptions import DuplicateRuleError
 from test.testlib.testcase import BaseTestCase
 from cfnlint.template import Template
@@ -231,6 +232,26 @@ class rule1_e0000(CloudFormationLintRule):
         rules = RulesCollection()
         self.assertRaises(DuplicateRuleError, rules.extend, rules_to_add)
 
+    def test_repr(self):
+        class rule0_e0000(CloudFormationLintRule):
+            """Error Rule"""
+            id = 'E0000'
+            shortdesc = 'Rule A'
+            description = 'First rule'
+        class rule1_e0001(CloudFormationLintRule):
+            """Error Rule"""
+            id = 'E0001'
+            shortdesc = 'Rule B'
+            description = 'Second rule'
+        rules = RulesCollection()
+        rules.extend([rule0_e0000(), rule1_e0001()])
+
+        retval = repr(rules)
+        pattern = r"\AE0000: Rule A\nFirst rule\nE0001: Rule B\nSecond rule\Z"
+        match = re.match(pattern, retval)
+        assert match, f"{retval} does not match {pattern}"
+
+
 class TestCreateFromModule(BaseTestCase):
     """Test loading a rules collection from a module"""