codeveto 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. codeveto/__init__.py +3 -0
  2. codeveto/__main__.py +8 -0
  3. codeveto/ai/__init__.py +19 -0
  4. codeveto/ai/harness.py +303 -0
  5. codeveto/ai/packets.py +855 -0
  6. codeveto/ai/policy.py +222 -0
  7. codeveto/ai/prompt.py +101 -0
  8. codeveto/ai/providers/__init__.py +178 -0
  9. codeveto/ai/providers/claude.py +247 -0
  10. codeveto/ai/providers/openai_compat.py +246 -0
  11. codeveto/ai/runner.py +293 -0
  12. codeveto/ai/verify.py +324 -0
  13. codeveto/anchor.py +211 -0
  14. codeveto/cli.py +247 -0
  15. codeveto/cli_explain.py +49 -0
  16. codeveto/cli_hook.py +31 -0
  17. codeveto/cli_init.py +254 -0
  18. codeveto/cli_mcp.py +29 -0
  19. codeveto/cli_packets.py +35 -0
  20. codeveto/cli_publish.py +29 -0
  21. codeveto/cli_review.py +362 -0
  22. codeveto/cli_rules.py +78 -0
  23. codeveto/cli_verify.py +47 -0
  24. codeveto/config.py +1229 -0
  25. codeveto/data/README.md +16 -0
  26. codeveto/data/ai-wire.schema.json +53 -0
  27. codeveto/data/prompts/system.md +57 -0
  28. codeveto/data/report-v1.schema.json +268 -0
  29. codeveto/data/templates/forgejo-codeveto.yml +104 -0
  30. codeveto/data/templates/github-codeveto.yml +18 -0
  31. codeveto/embedded.py +311 -0
  32. codeveto/engine.py +1570 -0
  33. codeveto/git.py +1549 -0
  34. codeveto/globs.py +348 -0
  35. codeveto/integrations/__init__.py +1 -0
  36. codeveto/integrations/hooks.py +327 -0
  37. codeveto/integrations/mcp.py +770 -0
  38. codeveto/integrations/mcp_ai.py +77 -0
  39. codeveto/integrations/prepush.py +222 -0
  40. codeveto/jsonsafe.py +60 -0
  41. codeveto/languages.py +539 -0
  42. codeveto/lexers.py +2560 -0
  43. codeveto/model.py +372 -0
  44. codeveto/publish/__init__.py +28 -0
  45. codeveto/publish/action.py +330 -0
  46. codeveto/publish/common.py +84 -0
  47. codeveto/publish/diff.py +208 -0
  48. codeveto/publish/event.py +241 -0
  49. codeveto/publish/forgejo.py +184 -0
  50. codeveto/publish/github.py +380 -0
  51. codeveto/publish/http.py +263 -0
  52. codeveto/publish/pull.py +218 -0
  53. codeveto/publish/untrusted.py +110 -0
  54. codeveto/py.typed +0 -0
  55. codeveto/redact.py +113 -0
  56. codeveto/render/__init__.py +64 -0
  57. codeveto/render/agent.py +43 -0
  58. codeveto/render/github.py +101 -0
  59. codeveto/render/json.py +23 -0
  60. codeveto/render/markdown.py +208 -0
  61. codeveto/render/safe.py +249 -0
  62. codeveto/render/sarif.py +217 -0
  63. codeveto/render/text.py +210 -0
  64. codeveto/report.py +252 -0
  65. codeveto/rules/__init__.py +84 -0
  66. codeveto/rules/agent.py +2972 -0
  67. codeveto/rules/base.py +1026 -0
  68. codeveto/rules/ci.py +1708 -0
  69. codeveto/rules/config.py +493 -0
  70. codeveto/rules/deps.py +1693 -0
  71. codeveto/rules/docker.py +479 -0
  72. codeveto/rules/examples/__init__.py +148 -0
  73. codeveto/rules/examples/agent.py +839 -0
  74. codeveto/rules/examples/ci.py +1046 -0
  75. codeveto/rules/examples/config.py +191 -0
  76. codeveto/rules/examples/deps.py +369 -0
  77. codeveto/rules/examples/docker.py +157 -0
  78. codeveto/rules/examples/go.py +241 -0
  79. codeveto/rules/examples/hygiene.py +466 -0
  80. codeveto/rules/examples/js.py +462 -0
  81. codeveto/rules/examples/python.py +595 -0
  82. codeveto/rules/examples/rust.py +268 -0
  83. codeveto/rules/examples/secrets.py +561 -0
  84. codeveto/rules/examples/security.py +608 -0
  85. codeveto/rules/examples/shell.py +174 -0
  86. codeveto/rules/examples/sql.py +194 -0
  87. codeveto/rules/examples/tests.py +497 -0
  88. codeveto/rules/go.py +328 -0
  89. codeveto/rules/hygiene.py +1094 -0
  90. codeveto/rules/js.py +768 -0
  91. codeveto/rules/python.py +1642 -0
  92. codeveto/rules/rust.py +209 -0
  93. codeveto/rules/secrets.py +1335 -0
  94. codeveto/rules/security.py +3680 -0
  95. codeveto/rules/shell.py +867 -0
  96. codeveto/rules/sql.py +629 -0
  97. codeveto/rules/tests.py +1404 -0
  98. codeveto/schema.py +384 -0
  99. codeveto/statements.py +607 -0
  100. codeveto/worktree.py +1176 -0
  101. codeveto/yamlish.py +1179 -0
  102. codeveto-0.1.0.dist-info/METADATA +253 -0
  103. codeveto-0.1.0.dist-info/RECORD +106 -0
  104. codeveto-0.1.0.dist-info/WHEEL +4 -0
  105. codeveto-0.1.0.dist-info/entry_points.txt +2 -0
  106. codeveto-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,191 @@
1
+ """Examples for the config pack."""
2
+
3
+ from codeveto.rules.base import bad, good
4
+
5
+ EXAMPLES = {
6
+ "config/invalid-json": [
7
+ bad(
8
+ "config/regions.json",
9
+ '{\n "eu": "eu-west-1",\n "us": "us-east-1"\n "ap": "ap-south-1"\n}\n',
10
+ old='{\n "eu": "eu-west-1",\n "us": "us-east-1"\n}\n',
11
+ expect=[("config/regions.json", 4, "new")],
12
+ note="A missing comma after the previous entry; reported at the added line.",
13
+ ),
14
+ bad(
15
+ "package.json",
16
+ '{\n "name": "shop",\n // build with vite\n "private": true\n}\n',
17
+ expect=[("package.json", 3, "new")],
18
+ note="package.json is strict JSON: npm rejects comments.",
19
+ ),
20
+ bad(
21
+ "tsconfig.json",
22
+ '{\n "compilerOptions": {\n "strict": true,\n // expect\n}\n',
23
+ old='{\n "compilerOptions": {\n "strict": true,\n }\n}\n',
24
+ note="JSONC allows comments and trailing commas, not a missing brace.",
25
+ ),
26
+ good(
27
+ "tsconfig.json",
28
+ '{\n // Strict mode for the app.\n "compilerOptions": {\n'
29
+ ' "strict": true, /* keep */\n "target": "es2022",\n },\n}\n',
30
+ note="tsconfig files are JSON with comments and trailing commas.",
31
+ ),
32
+ good(
33
+ ".vscode/settings.json",
34
+ '{\n "editor.formatOnSave": true, // team default\n}\n',
35
+ ),
36
+ good(
37
+ "config/broken.json",
38
+ '{\n "a": 1,\n "b": 2,\n "c":\n}\n',
39
+ old='{\n "a": 1,\n "c":\n}\n',
40
+ note="The file was already invalid before the change.",
41
+ ),
42
+ good(
43
+ "tests/fixtures/truncated.json",
44
+ '{"items": [1, 2,\n',
45
+ note="Parser tests keep broken samples on purpose.",
46
+ ),
47
+ good(
48
+ "internal/scan/testdata/truncated.json",
49
+ '{"items": [1, 2,\n',
50
+ note="Go keeps test inputs in testdata directories.",
51
+ ),
52
+ good(
53
+ "packages/config/tsconfigs/base.json",
54
+ '{\n // Shared by every package.\n "compilerOptions": {\n "strict": true,\n },\n}\n',
55
+ note="A TypeScript config under another name: TypeScript reads it as JSONC.",
56
+ ),
57
+ bad(
58
+ "events/run.json",
59
+ '{"action": "start"}\n{"action": "pass"} // expect\n',
60
+ note="JSON Lines in a .json file: reported as a warning, not an error.",
61
+ ),
62
+ ],
63
+ "config/duplicate-json-key": [
64
+ bad(
65
+ "package.json",
66
+ '{\n "name": "shop",\n "scripts": {\n "build": "vite build",\n'
67
+ ' "test": "vitest",\n "build": "tsc && vite build"\n }\n}\n',
68
+ old='{\n "name": "shop",\n "scripts": {\n "build": "vite build",\n'
69
+ ' "test": "vitest"\n }\n}\n',
70
+ expect=[("package.json", 6, "new")],
71
+ note="The second build script silently replaces the first.",
72
+ ),
73
+ bad(
74
+ ".vscode/settings.json",
75
+ '{\n "editor.tabSize": 2,\n "files.eol": "\\n",\n'
76
+ ' "editor.tabSize": 4 // expect\n}\n',
77
+ ),
78
+ good(
79
+ "config/menu.json",
80
+ '{\n "main": {"id": 1},\n "footer": {"id": 2}\n}\n',
81
+ note="The same key in different objects is fine.",
82
+ ),
83
+ good(
84
+ "package.json",
85
+ '{\n "//": "scripts run in CI",\n "name": "shop",\n'
86
+ ' "//": "keep the engines field in sync"\n}\n',
87
+ note="npm documents repeated \"//\" keys as comments.",
88
+ ),
89
+ ],
90
+ "config/invalid-toml": [
91
+ bad(
92
+ "pyproject.toml",
93
+ '[project]\nname = "shop"\nversion = "1.2.0\n',
94
+ old='[project]\nname = "shop"\nversion = "1.1.0"\n',
95
+ expect=[("pyproject.toml", 3, "new")],
96
+ note="An unterminated string.",
97
+ ),
98
+ bad(
99
+ "config/app.toml",
100
+ '[server]\nport = 8080\n\n[server] # expect\nhost = "0.0.0.0"\n',
101
+ old="[server]\nport = 8080\n",
102
+ note="TOML forbids defining a table twice.",
103
+ ),
104
+ good(
105
+ "config/app.toml",
106
+ '[server]\nport = 8080\nhost = "0.0.0.0"\n\n[server.tls]\nenabled = true\n',
107
+ ),
108
+ good(
109
+ "Cargo.toml",
110
+ '[package]\nname = "shop"\nedition = "2021"\n\n[dependencies]\n'
111
+ 'serde = { version = "1", features = ["derive"] }\n',
112
+ ),
113
+ ],
114
+ "config/invalid-yaml": [
115
+ bad(
116
+ "config/app.yaml",
117
+ "server:\n port: 8080\n host: \"0.0.0.0 # expect\n",
118
+ old="server:\n port: 8080\n",
119
+ note="An unterminated double-quoted scalar.",
120
+ ),
121
+ bad(
122
+ "deploy/values.yaml",
123
+ "replicas: 2\nimage: shop:1.4 tag: stable # expect\n",
124
+ old="replicas: 2\nimage: shop:1.4\n",
125
+ note="A mapping key where a value is required.",
126
+ ),
127
+ good(
128
+ "config/app.yaml",
129
+ "server:\n port: 8080\n banner: |\n Welcome: \"quoted\n text\n",
130
+ note="Block scalar bodies are text.",
131
+ ),
132
+ good(
133
+ "charts/shop/templates/deployment.yaml",
134
+ "spec:\n replicas: {{ .Values.replicas }}\n template:\n"
135
+ " {{- include \"labels\" . | nindent 4 }}\n",
136
+ note="Helm templates are not YAML until rendered.",
137
+ ),
138
+ ],
139
+ "config/yaml-tab-indent": [
140
+ bad(
141
+ "config/app.yaml",
142
+ "server:\n port: 8080\n\thost: localhost # expect\n",
143
+ old="server:\n port: 8080\n",
144
+ ),
145
+ bad(
146
+ ".gitlab-ci.yml",
147
+ "test:\n\tscript: make test # expect\n",
148
+ ),
149
+ good(
150
+ "config/app.yaml",
151
+ "motd: |\n Columns:\n \tname\tvalue\n",
152
+ note="Tabs inside a block scalar body are content.",
153
+ ),
154
+ good(
155
+ "config/app.yaml",
156
+ "server:\n port: 8080\n host: localhost\t# tab before a comment\n",
157
+ note="A tab after the content is not indentation.",
158
+ ),
159
+ good(
160
+ "config/notes.yaml",
161
+ "summary: first line\n \tsecond line of the same value\n",
162
+ note="A tab after the indentation may lead a plain scalar's continuation line.",
163
+ ),
164
+ bad(
165
+ "config/app.yaml",
166
+ "server:\n port: 8080\n \thost: localhost # expect\n",
167
+ note="Spaces then a tab before a key are still tab indentation.",
168
+ ),
169
+ ],
170
+ "config/duplicate-yaml-key": [
171
+ bad(
172
+ "config/app.yaml",
173
+ "server:\n port: 8080\n host: localhost\n port: 9090 # expect\n",
174
+ old="server:\n port: 8080\n host: localhost\n",
175
+ note="Most loaders keep the last port and drop the first.",
176
+ ),
177
+ bad(
178
+ "docker-compose.yml",
179
+ "services:\n web:\n image: shop\n web: # expect\n image: shop-next\n",
180
+ ),
181
+ good(
182
+ "config/app.yaml",
183
+ "primary:\n port: 8080\nreplica:\n port: 8081\n",
184
+ note="The same key in different mappings is fine.",
185
+ ),
186
+ good(
187
+ "config/list.yaml",
188
+ "- name: a\n port: 1\n- name: b\n port: 2\n",
189
+ ),
190
+ ],
191
+ }
@@ -0,0 +1,369 @@
1
+ """Examples for the deps pack."""
2
+
3
+ from codeveto.rules.base import Change, Example, bad, good
4
+
5
+
6
+ def _lock(resolved: str, version: str = "4.17.21") -> str:
7
+ return f"""{{
8
+ "name": "shop",
9
+ "version": "1.0.0",
10
+ "lockfileVersion": 3,
11
+ "requires": true,
12
+ "packages": {{
13
+ "": {{
14
+ "name": "shop",
15
+ "version": "1.0.0",
16
+ "dependencies": {{
17
+ "lodash": "^4.17.21"
18
+ }}
19
+ }},
20
+ "node_modules/lodash": {{
21
+ "version": "{version}",
22
+ "resolved": "{resolved}",
23
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17Lh=="
24
+ }}
25
+ }}
26
+ }}
27
+ """
28
+
29
+
30
+ def _package(deps: str, scripts: str = ' "test": "vitest run"\n') -> str:
31
+ return (
32
+ '{\n "name": "shop",\n "version": "1.0.0",\n "scripts": {\n'
33
+ + scripts
34
+ + ' },\n "dependencies": {\n'
35
+ + deps
36
+ + " }\n}\n"
37
+ )
38
+
39
+
40
+ SUB_A = "a" * 40
41
+ SUB_B = "b" * 40
42
+
43
+ GITMODULES = """[submodule "vendor/protocol"]
44
+ \tpath = vendor/protocol
45
+ \turl = {url}
46
+ """
47
+
48
+ CARGO_LOCK = """version = 4
49
+
50
+ [[package]]
51
+ name = "serde"
52
+ version = "1.0.219"
53
+ source = "{source}"
54
+ checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
55
+ """
56
+
57
+ EXAMPLES = {
58
+ "deps/registry-override": [
59
+ bad(".npmrc", "registry=https://npm.packages.example.net/ # expect\n"),
60
+ bad(
61
+ "requirements.txt",
62
+ "--extra-index-url https://pkgs.example.net/simple # expect\nrequests==2.32.3\n",
63
+ old="requests==2.32.3\n",
64
+ note="An extra index enables dependency confusion.",
65
+ ),
66
+ bad(
67
+ "pyproject.toml",
68
+ '[project]\nname = "shop"\nversion = "1.0"\n\n[[tool.uv.index]]\nname = "internal"\n'
69
+ 'url = "https://pypi.internal.example.com/simple" # expect\n',
70
+ ),
71
+ bad(
72
+ ".cargo/config.toml",
73
+ '[source.crates-io]\nreplace-with = "mirror" # expect\n\n'
74
+ '[source.mirror]\nregistry = "sparse+https://crates.example.org/index/" # expect\n',
75
+ note="replace-with is an error; the replacement source it names is a warning.",
76
+ ),
77
+ bad(
78
+ ".npmrc",
79
+ "@acme:registry=https://npm.pkg.github.com/ # expect\n",
80
+ note="A scoped registry serves only @acme packages: a warning.",
81
+ ),
82
+ bad(
83
+ "pyproject.toml",
84
+ '[project]\nname = "shop"\nversion = "1.0"\n\n[[tool.uv.index]]\nname = "torch"\n'
85
+ 'url = "https://download.pytorch.org/whl/cpu" # expect\nexplicit = true\n',
86
+ note="An explicit uv index is used only by packages that name it: a warning.",
87
+ ),
88
+ good(
89
+ ".npmrc",
90
+ "registry=https://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n"
91
+ "save-exact=true\n",
92
+ note="The public default, and an auth line for it.",
93
+ ),
94
+ good(
95
+ "pip.conf",
96
+ "[global]\nindex-url = ${PIP_INDEX_URL}\ntimeout = 60\n",
97
+ note="A value from the environment is not judged.",
98
+ ),
99
+ ],
100
+ "deps/lockfile-source-changed": [
101
+ bad(
102
+ "package-lock.json",
103
+ _lock("https://registry.npm-mirror.example.net/lodash/-/lodash-4.17.21.tgz").replace(
104
+ '.tgz",', '.tgz", // expect', 1
105
+ ),
106
+ old=_lock("https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"),
107
+ note="Same version, now from another host.",
108
+ ),
109
+ bad(
110
+ "go.sum",
111
+ "golang.org/x/text v0.21.0 h1:ZmZaGJn4l2sHqXpUfUvGkhuhOGLwHlTxM0kkB/ZRUpE= // expect\n"
112
+ "golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=\n",
113
+ old="golang.org/x/text v0.21.0 h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=\n"
114
+ "golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=\n",
115
+ note="go.sum records checksums: a changed hash for the same version.",
116
+ ),
117
+ bad(
118
+ "Cargo.lock",
119
+ CARGO_LOCK.format(
120
+ source="git+https://github.com/example-fork/serde?branch=main#0123abc"
121
+ ).replace('main#0123abc"', 'main#0123abc" # expect'),
122
+ old=CARGO_LOCK.format(source="registry+https://github.com/rust-lang/crates.io-index"),
123
+ ),
124
+ good(
125
+ "package-lock.json",
126
+ _lock("https://registry.npmjs.org/lodash/-/lodash-4.17.22.tgz", "4.17.22"),
127
+ old=_lock("https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"),
128
+ note="A version bump from the same registry.",
129
+ ),
130
+ good(
131
+ "Cargo.lock",
132
+ CARGO_LOCK.format(source="sparse+https://index.crates.io/"),
133
+ old=CARGO_LOCK.format(source="registry+https://github.com/rust-lang/crates.io-index"),
134
+ note="The crates.io Git and sparse indexes are the same registry.",
135
+ ),
136
+ ],
137
+ "deps/submodule-url-changed": [
138
+ bad(
139
+ ".gitmodules",
140
+ GITMODULES.format(url="https://github.com/someone-else/protocol.git").replace(
141
+ ".git\n", ".git # expect\n"
142
+ ),
143
+ old=GITMODULES.format(url="https://github.com/example/protocol.git"),
144
+ ),
145
+ bad(
146
+ ".gitmodules",
147
+ GITMODULES.format(url="git@git.example.net:example/protocol.git").replace(
148
+ ".git\n", ".git # expect\n"
149
+ ),
150
+ old=GITMODULES.format(url="git@github.com:example/protocol.git"),
151
+ note="Same path, another host.",
152
+ ),
153
+ good(
154
+ ".gitmodules",
155
+ GITMODULES.format(url="git@github.com:example/protocol.git"),
156
+ old=GITMODULES.format(url="https://github.com/example/protocol"),
157
+ note="HTTPS to SSH for the same repository.",
158
+ ),
159
+ good(
160
+ ".gitmodules",
161
+ GITMODULES.format(url="https://github.com/example/protocol.git")
162
+ + '[submodule "vendor/schemas"]\n\tpath = vendor/schemas\n'
163
+ "\turl = https://github.com/example/schemas.git\n",
164
+ old=GITMODULES.format(url="https://github.com/example/protocol.git"),
165
+ note="A new submodule is deps/submodule-changed.",
166
+ ),
167
+ ],
168
+ "deps/install-script-added": [
169
+ bad(
170
+ "package.json",
171
+ _package(
172
+ ' "lodash": "^4.17.21"\n',
173
+ ' "test": "vitest run",\n'
174
+ ' "postinstall": "node scripts/setup.js" // expect\n',
175
+ ),
176
+ old=_package(' "lodash": "^4.17.21"\n'),
177
+ ),
178
+ Example(
179
+ kind="bad",
180
+ files={
181
+ "build.rs": Change(
182
+ new='fn main() {\n println!("cargo:rerun-if-changed=x");\n}\n'
183
+ )
184
+ },
185
+ expect=(("build.rs", None, "new"),),
186
+ note="Cargo runs build.rs on every build.",
187
+ ),
188
+ bad(
189
+ "composer.json",
190
+ '{\n "require": {\n "monolog/monolog": "^3.0"\n },\n "scripts": {\n'
191
+ ' "post-install-cmd": "php bin/setup.php" // expect\n }\n}\n',
192
+ ),
193
+ good(
194
+ "package.json",
195
+ _package(' "lodash": "^4.17.21"\n', ' "test": "vitest run --coverage"\n'),
196
+ old=_package(' "lodash": "^4.17.21"\n'),
197
+ note="Only non-install scripts changed.",
198
+ ),
199
+ good(
200
+ "package.json",
201
+ _package(
202
+ ' "lodash": "^4.17.22"\n',
203
+ ' "test": "vitest run",\n "prepare": "husky"\n',
204
+ ),
205
+ old=_package(
206
+ ' "lodash": "^4.17.21"\n',
207
+ ' "test": "vitest run",\n "prepare": "husky"\n',
208
+ ),
209
+ note="The hook existed unchanged.",
210
+ ),
211
+ ],
212
+ "deps/url-dependency": [
213
+ bad(
214
+ "package.json",
215
+ _package(' "left-pad": "github:example/left-pad#main" // expect\n'),
216
+ ),
217
+ bad(
218
+ "requirements.txt",
219
+ "requests==2.32.3\n"
220
+ "git+https://github.com/example/toolkit.git@v1.2#egg=toolkit # expect\n",
221
+ old="requests==2.32.3\n",
222
+ ),
223
+ bad(
224
+ "Cargo.toml",
225
+ '[package]\nname = "shop"\nversion = "0.1.0"\n\n[dependencies]\n'
226
+ 'serde = "1"\ntoolkit = { git = "https://github.com/example/toolkit" } # expect\n',
227
+ ),
228
+ good("package.json", _package(' "lodash": "^4.17.21",\n "ui": "workspace:*"\n')),
229
+ good(
230
+ "pyproject.toml",
231
+ '[project]\nname = "shop"\nversion = "1.0"\ndependencies = [\n'
232
+ ' "httpx>=0.27",\n "shop-core",\n]\n\n[tool.uv.sources]\n'
233
+ "shop-core = { workspace = true }\n",
234
+ note="Workspace and local sources are not URL dependencies.",
235
+ ),
236
+ ],
237
+ "deps/insecure-registry": [
238
+ bad(".npmrc", "strict-ssl=false # expect\n"),
239
+ bad(
240
+ "pip.conf",
241
+ "[global]\nindex-url = https://pypi.org/simple\ntrusted-host = pypi.org # expect\n",
242
+ ),
243
+ bad(
244
+ "requirements.txt",
245
+ "--index-url http://pypi.internal.example.com/simple # expect\nrequests==2.32.3\n",
246
+ ),
247
+ good(".npmrc", "strict-ssl=true\nregistry=https://registry.npmjs.org/\n"),
248
+ good(
249
+ ".yarnrc.yml",
250
+ 'npmRegistryServer: "http://localhost:4873"\nenableStrictSsl: true\n',
251
+ note="A local registry (Verdaccio) for tests.",
252
+ ),
253
+ ],
254
+ "deps/lockfile-mismatch": [
255
+ Example(
256
+ kind="bad",
257
+ files={
258
+ "package.json": Change(
259
+ old=_package(' "lodash": "^4.17.21"\n'),
260
+ new=_package(' "lodash": "^4.17.21",\n "zod": "^3.24.0"\n'),
261
+ )
262
+ },
263
+ expect=(("package.json", 8, "new"),),
264
+ note="A new dependency without the lockfile.",
265
+ ),
266
+ Example(
267
+ kind="bad",
268
+ files={
269
+ "Cargo.lock": Change(
270
+ old=CARGO_LOCK.format(source="sparse+https://index.crates.io/"),
271
+ new=CARGO_LOCK.format(source="sparse+https://index.crates.io/").replace(
272
+ "1.0.219", "1.0.220"
273
+ ),
274
+ )
275
+ },
276
+ expect=(("Cargo.lock", 5, "new"),),
277
+ note="A lockfile change with no manifest change.",
278
+ ),
279
+ Example(
280
+ kind="good",
281
+ files={
282
+ "package.json": Change(
283
+ old=_package(' "lodash": "^4.17.21"\n'),
284
+ new=_package(' "lodash": "^4.17.22"\n'),
285
+ ),
286
+ "package-lock.json": Change(
287
+ old=_lock("https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"),
288
+ new=_lock("https://registry.npmjs.org/lodash/-/lodash-4.17.22.tgz", "4.17.22"),
289
+ ),
290
+ },
291
+ ),
292
+ Example(
293
+ kind="good",
294
+ files={
295
+ "web/package.json": Change(
296
+ old=_package(' "lodash": "^4.17.21"\n'),
297
+ new=_package(' "lodash": "^4.17.21"\n', ' "test": "vitest"\n'),
298
+ ),
299
+ "requirements.txt": Change(old="requests==2.32.3\n", new="requests==2.32.4\n"),
300
+ },
301
+ note="A script edit is no dependency change; requirements files are their own lock.",
302
+ ),
303
+ ],
304
+ "deps/submodule-changed": [
305
+ Example(
306
+ kind="bad",
307
+ files={"vendor/protocol": Change(old=SUB_A, new=SUB_B, mode="160000")},
308
+ expect=(("vendor/protocol", None, "new"),),
309
+ ),
310
+ Example(
311
+ kind="bad",
312
+ files={
313
+ "vendor/schemas": Change(new=SUB_A, mode="160000"),
314
+ ".gitmodules": Change(
315
+ new='[submodule "vendor/schemas"]\n\tpath = vendor/schemas\n'
316
+ "\turl = https://github.com/example/schemas.git\n"
317
+ ),
318
+ },
319
+ expect=(("vendor/schemas", None, "new"),),
320
+ note="A submodule added.",
321
+ ),
322
+ good(
323
+ ".gitmodules",
324
+ GITMODULES.format(url="https://github.com/example/protocol.git").replace(
325
+ "\turl", "\tbranch = main\n\turl"
326
+ ),
327
+ old=GITMODULES.format(url="https://github.com/example/protocol.git"),
328
+ ),
329
+ good("vendor/protocol/README.md", "# Protocol\n\nVendored copy.\n"),
330
+ ],
331
+ "deps/unpinned-version": [
332
+ bad(
333
+ "package.json",
334
+ _package(' "lodash": "*", // expect\n "react": "latest" // expect\n'),
335
+ ),
336
+ bad(
337
+ "requirements.txt",
338
+ "requests # expect\nflask>=3.0 # expect\nhttpx==0.28.1\n",
339
+ ),
340
+ good("package.json", _package(' "lodash": "^4.17.21",\n "react": "19.1.0"\n')),
341
+ good("requirements.txt", "requests>=2.31,<3\nhttpx==0.28.1\n-r base.txt\n"),
342
+ ],
343
+ "deps/new-dependency": [
344
+ bad(
345
+ "package.json",
346
+ _package(' "lodash": "^4.17.21",\n "zod": "^3.24.0" // expect\n'),
347
+ old=_package(' "lodash": "^4.17.21"\n'),
348
+ ),
349
+ bad(
350
+ "go.mod",
351
+ "module example.com/shop\n\ngo 1.24\n\nrequire (\n"
352
+ "\tgithub.com/google/uuid v1.6.0\n\tgolang.org/x/text v0.21.0 // expect\n)\n",
353
+ old="module example.com/shop\n\ngo 1.24\n\nrequire (\n"
354
+ "\tgithub.com/google/uuid v1.6.0\n)\n",
355
+ ),
356
+ good(
357
+ "package.json",
358
+ _package(' "lodash": "^4.17.22"\n'),
359
+ old=_package(' "lodash": "^4.17.21"\n'),
360
+ note="A version bump is not a new dependency.",
361
+ ),
362
+ good(
363
+ "requirements.txt",
364
+ "httpx==0.28.1\nrequests==2.32.3\n",
365
+ old="requests==2.32.3\nhttpx==0.28.1\n",
366
+ note="Reordering is not adding.",
367
+ ),
368
+ ],
369
+ }