Skip to content

Commit 363f8b5

Browse files
committed
fix: resolve markdown linting errors caught in CI
- Add blank lines around lists, headings, and code blocks (MD022, MD031, MD032) - Standardize list style to dashes (MD004) - Add language specifications to code blocks (MD040) - Remove trailing spaces (MD009) - Add trailing newline to KNOWN_ISSUES.md (MD047) - Standardize bold style to underscores (MD050) These errors were caught by GitHub Super-Linter but not by local auto-fix. All 7 files now pass markdownlint validation.
1 parent 90cf6a5 commit 363f8b5

File tree

7 files changed

+125
-57
lines changed

7 files changed

+125
-57
lines changed

.kiro/specs/python-testing-framework/design.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This design describes a pytest-based testing framework for the Secure Coding Gui
88

99
### High-Level Structure
1010

11-
```
11+
```text
1212
docs/Secure-Coding-Guide-for-Python/
1313
├── tests/ # New testing directory
1414
│ ├── __init__.py
@@ -26,7 +26,7 @@ docs/Secure-Coding-Guide-for-Python/
2626

2727
### GitHub Actions Integration
2828

29-
```
29+
```text
3030
.github/workflows/
3131
├── linter.yml # Existing markdown linter
3232
└── python-tests.yml # New Python testing workflow
@@ -39,11 +39,13 @@ docs/Secure-Coding-Guide-for-Python/
3939
**Purpose**: Discover Python files and README.md files in the directory structure
4040

4141
**Key Functions**:
42+
4243
- `find_python_files(root_dir: str) -> List[Path]`: Recursively finds all `.py` files under the root directory, excluding the tests directory itself
4344
- `find_readme_files(root_dir: str) -> List[Path]`: Recursively finds all `README.md` files in CWE directories
4445
- `get_cwe_directories(root_dir: str) -> List[Path]`: Identifies all CWE-specific directories
4546

4647
**Implementation Notes**:
48+
4749
- Use `pathlib.Path` for cross-platform compatibility
4850
- Exclude template files and test files from validation
4951
- Cache results in pytest fixtures for performance
@@ -71,6 +73,7 @@ docs/Secure-Coding-Guide-for-Python/
7173
- Output: Pass/fail with import error details
7274

7375
**Implementation Strategy**:
76+
7477
- Use `pytest.mark.parametrize` with file list from scanner
7578
- Capture stdout/stderr during execution to prevent test output pollution
7679
- Use subprocess for isolated execution to prevent side effects
@@ -81,12 +84,14 @@ docs/Secure-Coding-Guide-for-Python/
8184
**Purpose**: Parse README.md files and extract structural elements
8285

8386
**Key Functions**:
87+
8488
- `parse_markdown(file_path: Path) -> Dict`: Parses markdown and returns structure
8589
- `extract_sections(content: str) -> List[str]`: Extracts all heading sections
8690
- `extract_code_references(content: str) -> List[str]`: Finds references to Python files (e.g., `compliant01.py`)
8791
- `validate_table_structure(content: str, table_name: str) -> bool`: Validates presence and structure of required tables
8892

8993
**Implementation Notes**:
94+
9095
- Use regex patterns to identify markdown elements
9196
- Consider using `markdown` library or simple regex for lightweight parsing
9297
- Return structured data for easy test assertions
@@ -125,6 +130,7 @@ docs/Secure-Coding-Guide-for-Python/
125130
- Output: Pass/fail with ordering issues
126131

127132
**Implementation Strategy**:
133+
128134
- Use markdown parser utility to extract structure
129135
- Compare against template requirements
130136
- Provide clear error messages indicating what's missing or incorrect
@@ -151,6 +157,7 @@ docs/Secure-Coding-Guide-for-Python/
151157
- Output: Pass/fail with broken index links
152158

153159
**Implementation Strategy**:
160+
154161
- Use `lychee` CLI tool for comprehensive link checking (supports internal and external links)
155162
- Alternative: Use `markdownlint-cli2` with link validation plugins
156163
- Wrap CLI tool execution in pytest tests for integration with test suite
@@ -162,12 +169,14 @@ docs/Secure-Coding-Guide-for-Python/
162169
**Purpose**: Centralize test configuration and shared fixtures
163170

164171
**Fixtures**:
172+
165173
- `python_files`: Session-scoped fixture returning list of all Python files to validate
166174
- `readme_files`: Session-scoped fixture returning list of all README.md files to validate
167175
- `project_root`: Fixture providing path to Secure-Coding-Guide-for-Python directory
168176
- `template_structure`: Fixture providing parsed template structure for comparison
169177

170178
**Configuration**:
179+
171180
- Set pytest markers for test categorization (`@pytest.mark.python`, `@pytest.mark.markdown`)
172181
- Configure test output formatting
173182
- Set up logging for detailed error reporting
@@ -177,6 +186,7 @@ docs/Secure-Coding-Guide-for-Python/
177186
**Purpose**: Modern Python project configuration following PEP 735 standards
178187

179188
**Configuration Structure**:
189+
180190
```toml
181191
[project]
182192
name = "secure-coding-guide-python-tests"
@@ -253,6 +263,7 @@ exclude_lines = [
253263
```
254264

255265
**Design Decisions**:
266+
256267
- Use PEP 735 `[dependency-groups]` instead of `[project.optional-dependencies]`
257268
- Separate `test` group (minimal) from `dev` group (includes linting/tox)
258269
- Configure pytest, ruff, and coverage in single file
@@ -264,6 +275,7 @@ exclude_lines = [
264275
**Purpose**: Enable local multi-version testing with the same matrix as CI/CD
265276

266277
**Configuration Structure**:
278+
267279
```ini
268280
[tox]
269281
requires = tox-uv
@@ -297,13 +309,15 @@ commands =
297309
```
298310

299311
**Design Decisions**:
312+
300313
- Use `requires = tox-uv` to enable uv integration
301314
- Use `groups = test` to install from PEP 735 dependency groups
302315
- Match CI/CD Python version matrix (3.9-3.14) for consistency
303316
- Include separate environments for linting and coverage
304317
- No `skipsdist` needed - tox-uv handles this automatically
305318

306319
**Local Usage**:
320+
307321
```bash
308322
# Install uv and tox
309323
uv pip install tox tox-uv
@@ -329,6 +343,7 @@ tox -e links
329343
**Purpose**: Automate test execution on pull requests and pushes using `uv`
330344

331345
**Workflow Structure**:
346+
332347
```yaml
333348
name: Python Tests
334349

@@ -381,6 +396,7 @@ jobs:
381396
```
382397
383398
**Design Decisions**:
399+
384400
- Test against multiple Python versions (3.9-3.14) to ensure broad compatibility and catch version-specific deprecation warnings
385401
- Use `astral-sh/setup-uv@v3` action with caching enabled for fast, reliable uv installation
386402
- Use `uv python install` to install specific Python version (uv manages Python versions)
@@ -392,6 +408,7 @@ jobs:
392408
- Use verbose output (`-v`) and short traceback (`--tb=short`) for readable CI logs
393409

394410
**Performance Benefits**:
411+
395412
- `uv` is 10-100x faster than pip for dependency resolution and installation
396413
- Parallel dependency downloads
397414
- Better caching in CI/CD environments
@@ -400,6 +417,7 @@ jobs:
400417
## Data Models
401418

402419
### Python File Validation Result
420+
403421
```python
404422
@dataclass
405423
class PythonValidationResult:
@@ -413,6 +431,7 @@ class PythonValidationResult:
413431
```
414432

415433
### Markdown Validation Result
434+
416435
```python
417436
@dataclass
418437
class MarkdownValidationResult:
@@ -456,6 +475,7 @@ class MarkdownValidationResult:
456475
### Unit Tests for Test Utilities
457476

458477
Create tests for the testing framework itself:
478+
459479
- `test_file_scanner.py`: Validate file discovery logic
460480
- `test_markdown_parser.py`: Validate markdown parsing logic
461481

@@ -484,11 +504,13 @@ Create tests for the testing framework itself:
484504
All dependencies are managed via PEP 735 dependency groups in `pyproject.toml`:
485505

486506
### Test Dependencies (dependency-groups.test)
507+
487508
- `pytest>=8.0.0` - Testing framework
488509
- `pytest-cov>=4.1.0` - Coverage reporting
489510
- `pytest-xdist>=3.5.0` - Parallel test execution
490511

491512
### Development Dependencies (dependency-groups.dev)
513+
492514
- All test dependencies plus:
493515
- `ruff>=0.4.0` - Fast Python linter and formatter
494516
- `tox>=4.0.0` - Multi-version testing orchestration
@@ -498,6 +520,7 @@ All dependencies are managed via PEP 735 dependency groups in `pyproject.toml`:
498520
### Installation
499521

500522
**Install uv** (one-time setup):
523+
501524
```bash
502525
# Linux/macOS
503526
curl -LsSf https://astral.sh/uv/install.sh | sh
@@ -513,6 +536,7 @@ brew install uv
513536
```
514537

515538
**Install project dependencies**:
539+
516540
```bash
517541
cd docs/Secure-Coding-Guide-for-Python
518542
@@ -532,6 +556,7 @@ uv run tox
532556
## Migration and Rollout
533557

534558
### Phase 1: Initial Implementation
559+
535560
1. Create `pyproject.toml` with PEP 735 dependency groups
536561
2. Create `tox.ini` with multi-version testing configuration
537562
3. Create test directory structure
@@ -541,19 +566,22 @@ uv run tox
541566
7. Test with subset of files
542567

543568
### Phase 2: Enhanced Validation
569+
544570
1. Add deprecation warning detection
545571
2. Add import validation
546572
3. Implement markdown parser utility
547573
4. Add markdown structure validation
548574

549575
### Phase 3: Refinement
576+
550577
1. Add code reference validation
551578
2. Add table structure validation
552579
3. Optimize performance with pytest-xdist
553580
4. Add ruff linting configuration
554581
5. Add documentation
555582

556583
### Phase 4: Documentation and Adoption
584+
557585
1. Add README in tests/ directory with local testing instructions
558586
2. Document uv and tox usage
559587
3. Update CONTRIBUTING.md with testing framework information

.kiro/specs/python-testing-framework/tasks.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ The Python testing framework is **complete and operational**. All core requireme
145145
## Requirements Coverage
146146

147147
**Requirement 1** (Python Code Validation): Fully implemented
148+
148149
- Syntax validation for all Python files using `ast.parse()`
149150
- Deprecation warning detection via subprocess execution
150151
- Recursive scanning of all CWE directories
@@ -153,13 +154,15 @@ The Python testing framework is **complete and operational**. All core requireme
153154
- Expected failure marker support for intentional issues
154155

155156
**Requirement 2** (Markdown Structure Validation): Fully implemented
157+
156158
- Template conformance validation
157159
- Required sections verification (title, introduction, Non-Compliant, Compliant, Automated Detection, Related Guidelines, Bibliography)
158160
- Missing section reporting with clear error messages
159161
- Code reference validation (compliant01.py, noncompliant01.py)
160162
- Recursive scanning of all CWE directories
161163

162164
**Requirement 3** (Automated CI/CD): Fully implemented
165+
163166
- GitHub Actions workflow triggers on pull requests and pushes
164167
- Automatic test execution with pytest across Python 3.9-3.14
165168
- Failure status reporting to pull requests
@@ -168,6 +171,7 @@ The Python testing framework is **complete and operational**. All core requireme
168171
- Fast execution with uv package manager
169172

170173
**Requirement 4** (Local Testing): Fully implemented
174+
171175
- Command-line execution with pytest
172176
- Clear installation instructions with uv in CONTRIBUTING.md
173177
- Identical results between local and CI environments
@@ -176,13 +180,15 @@ The Python testing framework is **complete and operational**. All core requireme
176180
- Multi-version testing with tox
177181

178182
**Requirement 5** (Link Validation): Fully implemented
183+
179184
- Internal link validation in README.md files
180185
- Code file link validation
181186
- Index table link validation in top-level readme.md
182187
- Broken link reporting with file path and target
183188
- Integration with lychee CLI tool in CI/CD for comprehensive checking
184189

185190
**Requirement 6** (Maintainability): Fully implemented
191+
186192
- Organized test code in dedicated `tests/` directory
187193
- Separated Python and Markdown validation logic into distinct modules
188194
- Pytest fixtures for common setup and configuration
@@ -206,6 +212,7 @@ The following tasks were considered but intentionally not implemented:
206212
**Status**: ✅ Production Ready
207213

208214
The testing framework is fully operational and meets all core requirements. It successfully validates:
215+
209216
- 661+ test cases across all Python code examples
210217
- All Markdown documentation structure and required sections
211218
- All internal links and code references

.kiro/steering/python-secure-coding.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ An educational resource providing secure coding guidance for CPython >= 3.9 with
5454
### What NOT to Include in Examples
5555

5656
Code examples are educational only, NOT production-ready. They intentionally omit:
57+
5758
- Inline documentation
5859
- Custom exceptions
5960
- Full descriptive variable names
@@ -74,7 +75,7 @@ Use `# TODO:` comments for aspects not covered.
7475

7576
### Example Structure
7677

77-
```
78+
```text
7879
docs/Secure-Coding-Guide-for-Python/
7980
├── CWE-707/ # Pillar
8081
│ └── CWE-89/ # Rule (Base/Variant/Class)
@@ -111,12 +112,14 @@ Each rule's README.md must include:
111112
## Branch Naming
112113

113114
Use prefix `pySCG-` for Python Secure Coding Guide branches:
115+
114116
- `pySCG-issue-123`
115117
- `pySCG-add-logging-feature`
116118

117119
## Review Requirements
118120

119121
Pull requests require approval from:
122+
120123
1. At least one core team member for this Python project
121124
2. At least one additional reviewer (can be any GitHub user)
122125

.kiro/steering/tech.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
## Build System & Tools
44

55
- **Package Manager**: npm
6-
- **Linting & Formatting**:
6+
- **Linting & Formatting**:
77
- Prettier for code formatting
88
- markdownlint-cli for Markdown linting
99
- GitHub Super-Linter for CI/CD validation
1010

1111
## Documentation Publishing
1212

1313
The project uses the **Simplest Possible Process (SPP)** for publishing documentation:
14+
1415
- **Static Site Generator**: Jekyll (GitHub Pages default)
1516
- **Markdown Processor**: kramdown (default)
1617
- **Template**: Minima (default Jekyll theme)

0 commit comments

Comments
 (0)