Skip to content

Commit c42a3c9

Browse files
fix: Correct pre-commit template path in PrecommitHooksFixer (ambient-code#269)
* fix precommit hook template path reference in PrecommitHooksFixer Signed-off-by: Rahul Shetty <rashetty@redhat.com> * fix format issue Signed-off-by: Rahul Shetty <rashetty@redhat.com> --------- Signed-off-by: Rahul Shetty <rashetty@redhat.com>
1 parent 248cc98 commit c42a3c9

11 files changed

Lines changed: 65 additions & 126 deletions

src/agentready/assessors/documentation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ def _create_remediation(self) -> Remediation:
453453
],
454454
tools=[],
455455
commands=[],
456-
examples=[
457-
"""# Project Name
456+
examples=["""# Project Name
458457
459458
## Overview
460459
What this project does and why it exists.
@@ -477,8 +476,7 @@ def _create_remediation(self) -> Remediation:
477476
# Format code
478477
black .
479478
```
480-
"""
481-
],
479+
"""],
482480
citations=[
483481
Citation(
484482
source="GitHub",

src/agentready/assessors/testing.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ def _create_remediation(self) -> Remediation:
286286
"pre-commit install",
287287
"pre-commit run --all-files",
288288
],
289-
examples=[
290-
"""# .pre-commit-config.yaml
289+
examples=["""# .pre-commit-config.yaml
291290
repos:
292291
- repo: https://github.com/pre-commit/pre-commit-hooks
293292
rev: v4.4.0
@@ -306,8 +305,7 @@ def _create_remediation(self) -> Remediation:
306305
rev: 5.12.0
307306
hooks:
308307
- id: isort
309-
"""
310-
],
308+
"""],
311309
citations=[
312310
Citation(
313311
source="pre-commit.com",

src/agentready/fixers/testing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ def generate_fix(self, repository: Repository, finding: Finding) -> Optional[Fix
4646
# Try to load language-specific template, fallback to python
4747
try:
4848
template = self.env_bootstrap.get_template(
49-
f"precommit-{primary_lang}.yaml.j2"
49+
f"{primary_lang}/precommit.yaml.j2"
5050
)
5151
except Exception:
52-
template = self.env_bootstrap.get_template("precommit-python.yaml.j2")
52+
# Template doesn't exist, fallback to python
53+
template = self.env_bootstrap.get_template("python/precommit.yaml.j2")
5354

5455
content = template.render()
5556

src/agentready/services/assessment_cache.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def _initialize_db(self) -> None:
3333
"""Initialize database schema."""
3434
try:
3535
with sqlite3.connect(self.db_path) as conn:
36-
conn.execute(
37-
"""
36+
conn.execute("""
3837
CREATE TABLE IF NOT EXISTS assessments (
3938
id INTEGER PRIMARY KEY AUTOINCREMENT,
4039
repository_url TEXT NOT NULL,
@@ -45,23 +44,18 @@ def _initialize_db(self) -> None:
4544
expires_at TIMESTAMP,
4645
UNIQUE(repository_url, commit_hash)
4746
)
48-
"""
49-
)
47+
""")
5048

5149
# Create index for faster queries
52-
conn.execute(
53-
"""
50+
conn.execute("""
5451
CREATE INDEX IF NOT EXISTS idx_repo_commit
5552
ON assessments(repository_url, commit_hash)
56-
"""
57-
)
53+
""")
5854

59-
conn.execute(
60-
"""
55+
conn.execute("""
6156
CREATE INDEX IF NOT EXISTS idx_expires_at
6257
ON assessments(expires_at)
63-
"""
64-
)
58+
""")
6559

6660
conn.commit()
6761
except sqlite3.Error as e:

tests/e2e/test_critical_paths.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,12 @@ def test_assess_with_valid_config(self):
276276
with tempfile.TemporaryDirectory() as tmp_dir:
277277
# Create valid config file
278278
config_file = Path(tmp_dir) / "config.yaml"
279-
config_file.write_text(
280-
"""
279+
config_file.write_text("""
281280
weights:
282281
claude_md: 2.0
283282
excluded_attributes:
284283
- repomix_config
285-
"""
286-
)
284+
""")
287285

288286
output_dir = Path(tmp_dir) / "output"
289287

tests/e2e/test_critical_paths_simplified.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,12 @@ def test_valid_config_application(self, temp_output_dir):
219219
with tempfile.TemporaryDirectory() as tmp_dir:
220220
# Create valid config
221221
config_file = Path(tmp_dir) / "config.yaml"
222-
config_file.write_text(
223-
"""
222+
config_file.write_text("""
224223
weights:
225224
claude_md: 2.0
226225
excluded_attributes:
227226
- repomix_config
228-
"""
229-
)
227+
""")
230228

231229
# Run assessment with config
232230
result = helper.run_assessment(

tests/unit/cli/test_main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,12 @@ class TestConfigLoading:
355355
def test_load_config_valid_yaml(self, tmp_path):
356356
"""Test loading valid config file."""
357357
config_file = tmp_path / "config.yaml"
358-
config_file.write_text(
359-
"""
358+
config_file.write_text("""
360359
weights:
361360
claude_md_file: 2.0
362361
excluded_attributes:
363362
- test_attribute
364-
"""
365-
)
363+
""")
366364

367365
config = load_config(config_file)
368366

tests/unit/test_assessors_code_quality.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@ def test_python_pylint_configured(self, tmp_path):
6969

7070
# Create .pylintrc
7171
pylintrc = tmp_path / ".pylintrc"
72-
pylintrc.write_text(
73-
"""[MASTER]
72+
pylintrc.write_text("""[MASTER]
7473
max-line-length=100
7574
7675
[MESSAGES CONTROL]
7776
disable=C0111
78-
"""
79-
)
77+
""")
8078

8179
repo = Repository(
8280
path=tmp_path,
@@ -105,11 +103,9 @@ def test_python_ruff_configured(self, tmp_path):
105103

106104
# Create ruff.toml
107105
ruff_toml = tmp_path / "ruff.toml"
108-
ruff_toml.write_text(
109-
"""line-length = 100
106+
ruff_toml.write_text("""line-length = 100
110107
select = ["E", "F", "W"]
111-
"""
112-
)
108+
""")
113109

114110
repo = Repository(
115111
path=tmp_path,
@@ -135,14 +131,12 @@ def test_python_pyproject_toml(self, tmp_path):
135131

136132
# Create pyproject.toml with both tools
137133
pyproject = tmp_path / "pyproject.toml"
138-
pyproject.write_text(
139-
"""[tool.pylint]
134+
pyproject.write_text("""[tool.pylint]
140135
max-line-length = 100
141136
142137
[tool.ruff]
143138
line-length = 100
144-
"""
145-
)
139+
""")
146140

147141
repo = Repository(
148142
path=tmp_path,
@@ -171,15 +165,13 @@ def test_javascript_eslint_configured(self, tmp_path):
171165

172166
# Create .eslintrc.json
173167
eslintrc = tmp_path / ".eslintrc.json"
174-
eslintrc.write_text(
175-
"""{
168+
eslintrc.write_text("""{
176169
"extends": "eslint:recommended",
177170
"rules": {
178171
"no-console": "warn"
179172
}
180173
}
181-
"""
182-
)
174+
""")
183175

184176
repo = Repository(
185177
path=tmp_path,
@@ -234,14 +226,12 @@ def test_ruby_rubocop_configured(self, tmp_path):
234226

235227
# Create .rubocop.yml
236228
rubocop = tmp_path / ".rubocop.yml"
237-
rubocop.write_text(
238-
"""AllCops:
229+
rubocop.write_text("""AllCops:
239230
TargetRubyVersion: 3.0
240231
241232
Style/StringLiterals:
242233
EnforcedStyle: double_quotes
243-
"""
244-
)
234+
""")
245235

246236
repo = Repository(
247237
path=tmp_path,
@@ -269,14 +259,12 @@ def test_go_golangci_lint_configured(self, tmp_path):
269259

270260
# Create .golangci.yml
271261
golangci = tmp_path / ".golangci.yml"
272-
golangci.write_text(
273-
"""linters:
262+
golangci.write_text("""linters:
274263
enable:
275264
- gofmt
276265
- golint
277266
- govet
278-
"""
279-
)
267+
""")
280268

281269
repo = Repository(
282270
path=tmp_path,
@@ -311,14 +299,12 @@ def test_actionlint_in_precommit(self, tmp_path):
311299

312300
# Create .pre-commit-config.yaml with actionlint
313301
precommit = tmp_path / ".pre-commit-config.yaml"
314-
precommit.write_text(
315-
"""repos:
302+
precommit.write_text("""repos:
316303
- repo: https://github.com/rhysd/actionlint
317304
rev: v1.6.0
318305
hooks:
319306
- id: actionlint
320-
"""
321-
)
307+
""")
322308

323309
repo = Repository(
324310
path=tmp_path,
@@ -344,13 +330,11 @@ def test_markdownlint_configured(self, tmp_path):
344330

345331
# Create .markdownlint.json
346332
markdownlint = tmp_path / ".markdownlint.json"
347-
markdownlint.write_text(
348-
"""{
333+
markdownlint.write_text("""{
349334
"default": true,
350335
"MD013": false
351336
}
352-
"""
353-
)
337+
""")
354338

355339
repo = Repository(
356340
path=tmp_path,

tests/unit/test_assessors_containers.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ def test_multi_stage_build(self, tmp_path):
9898

9999
# Create multi-stage Dockerfile
100100
dockerfile = tmp_path / "Dockerfile"
101-
dockerfile.write_text(
102-
"""FROM node:18 AS builder
101+
dockerfile.write_text("""FROM node:18 AS builder
103102
WORKDIR /app
104103
COPY . .
105104
RUN npm ci && npm run build
@@ -108,8 +107,7 @@ def test_multi_stage_build(self, tmp_path):
108107
WORKDIR /app
109108
COPY --from=builder /app/dist ./dist
110109
CMD ["node", "dist/index.js"]
111-
"""
112-
)
110+
""")
113111

114112
repo = Repository(
115113
path=tmp_path,
@@ -138,15 +136,13 @@ def test_docker_compose(self, tmp_path):
138136

139137
# Create docker-compose.yml
140138
compose = tmp_path / "docker-compose.yml"
141-
compose.write_text(
142-
"""version: '3.8'
139+
compose.write_text("""version: '3.8'
143140
services:
144141
app:
145142
build: .
146143
ports:
147144
- "8000:8000"
148-
"""
149-
)
145+
""")
150146

151147
repo = Repository(
152148
path=tmp_path,
@@ -177,15 +173,13 @@ def test_dockerignore_file(self, tmp_path):
177173

178174
# Create .dockerignore
179175
dockerignore = tmp_path / ".dockerignore"
180-
dockerignore.write_text(
181-
""".git
176+
dockerignore.write_text(""".git
182177
.venv
183178
__pycache__
184179
*.pyc
185180
.env
186181
node_modules
187-
"""
188-
)
182+
""")
189183

190184
repo = Repository(
191185
path=tmp_path,
@@ -239,14 +233,12 @@ def test_comprehensive_container_setup(self, tmp_path):
239233
subprocess.run(["git", "init"], cwd=tmp_path, capture_output=True, check=True)
240234

241235
# Multi-stage Dockerfile
242-
(tmp_path / "Dockerfile").write_text(
243-
"""FROM python:3.12 AS builder
236+
(tmp_path / "Dockerfile").write_text("""FROM python:3.12 AS builder
244237
RUN pip install build
245238
246239
FROM python:3.12-slim
247240
COPY --from=builder /app /app
248-
"""
249-
)
241+
""")
250242

251243
# docker-compose.yml
252244
(tmp_path / "docker-compose.yml").write_text(

0 commit comments

Comments
 (0)