@opensip-cli/checks-go 0.1.0
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.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/__tests__/fixture-coverage.allowlist.d.ts +17 -0
- package/dist/__tests__/fixture-coverage.allowlist.d.ts.map +1 -0
- package/dist/__tests__/fixture-coverage.allowlist.js +16 -0
- package/dist/__tests__/fixture-coverage.allowlist.js.map +1 -0
- package/dist/__tests__/fixture-coverage.test.d.ts +13 -0
- package/dist/__tests__/fixture-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/fixture-coverage.test.js +57 -0
- package/dist/__tests__/fixture-coverage.test.js.map +1 -0
- package/dist/__tests__/no-fmt-print.test.d.ts +2 -0
- package/dist/__tests__/no-fmt-print.test.d.ts.map +1 -0
- package/dist/__tests__/no-fmt-print.test.js +61 -0
- package/dist/__tests__/no-fmt-print.test.js.map +1 -0
- package/dist/__tests__/run.test.d.ts +2 -0
- package/dist/__tests__/run.test.d.ts.map +1 -0
- package/dist/__tests__/run.test.js +55 -0
- package/dist/__tests__/run.test.js.map +1 -0
- package/dist/checks/no-fmt-print.d.ts +22 -0
- package/dist/checks/no-fmt-print.d.ts.map +1 -0
- package/dist/checks/no-fmt-print.js +51 -0
- package/dist/checks/no-fmt-print.js.map +1 -0
- package/dist/display/index.d.ts +9 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +4 -0
- package/dist/display/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
OpenSIP CLI
|
|
2
|
+
Copyright 2026 opensip-ai
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this software except in compliance with the License. A copy of the License is
|
|
6
|
+
included in the LICENSE file and is also available at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- Generated by scripts/build-package-readmes.mjs — do not edit by hand.
|
|
2
|
+
Change the package's "description" (or the generator template) and run
|
|
3
|
+
`pnpm docs:readmes`. CI enforces sync via `pnpm docs:readmes:check`. -->
|
|
4
|
+
|
|
5
|
+
# @opensip-cli/checks-go
|
|
6
|
+
|
|
7
|
+
> Go fitness checks for opensip-cli
|
|
8
|
+
|
|
9
|
+
This is a **fitness check pack**. Install it alongside the `opensip-cli` CLI and its checks are discovered automatically.
|
|
10
|
+
|
|
11
|
+
Part of [**opensip-cli**](https://github.com/opensip-ai/opensip-cli) — an open-source codebase-analysis toolkit: fitness checks (`fit`), static call-graph analysis (`graph`), and simulation (`sim`).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Most users install the CLI, which bundles the first-party tools:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
curl -fsSL https://opensip.ai/cli/install.sh | bash
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This package is published for the CLI and advanced plugin authors; most users should not install `@opensip-cli/checks-go` directly.
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
- 📚 Project docs: https://opensip.ai/docs/opensip-cli/
|
|
26
|
+
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.0/docs/public/70-reference/02-package-catalog.md
|
|
27
|
+
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.0/packages/fitness/checks-go
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
Apache-2.0 © opensip-ai
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-check fixture-coverage allowlist for checks-go (testing gap P0).
|
|
3
|
+
*
|
|
4
|
+
* `ALLOWLIST` is currently empty: every shipped, fixture-exercisable check
|
|
5
|
+
* has clean+violation fixtures. A future entry would mean a check whose
|
|
6
|
+
* pass/fail fixture coverage is still owed.
|
|
7
|
+
*
|
|
8
|
+
* `COMMAND_EXEMPTIONS` are `analysisMode:'command'` checks that shell out to
|
|
9
|
+
* external tools and cannot be exercised by writing a fixture file; they are
|
|
10
|
+
* covered by the failure-mode / packed-smoke lanes instead (gap register).
|
|
11
|
+
*/
|
|
12
|
+
import type { CommandExemptions, CoverageAllowlist, FilenameOverrides } from '@opensip-cli/test-support';
|
|
13
|
+
export declare const ALLOWLIST: CoverageAllowlist;
|
|
14
|
+
export declare const COMMAND_EXEMPTIONS: CommandExemptions;
|
|
15
|
+
export declare const FILENAME_OVERRIDES: FilenameOverrides;
|
|
16
|
+
export declare const KNOWN_UNFIXTURABLE: CommandExemptions;
|
|
17
|
+
//# sourceMappingURL=fixture-coverage.allowlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-coverage.allowlist.d.ts","sourceRoot":"","sources":["../../src/__tests__/fixture-coverage.allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,SAAS,EAAE,iBAAsB,CAAC;AAE/C,eAAO,MAAM,kBAAkB,EAAE,iBAAsB,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,iBAAsB,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,iBAAsB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-check fixture-coverage allowlist for checks-go (testing gap P0).
|
|
3
|
+
*
|
|
4
|
+
* `ALLOWLIST` is currently empty: every shipped, fixture-exercisable check
|
|
5
|
+
* has clean+violation fixtures. A future entry would mean a check whose
|
|
6
|
+
* pass/fail fixture coverage is still owed.
|
|
7
|
+
*
|
|
8
|
+
* `COMMAND_EXEMPTIONS` are `analysisMode:'command'` checks that shell out to
|
|
9
|
+
* external tools and cannot be exercised by writing a fixture file; they are
|
|
10
|
+
* covered by the failure-mode / packed-smoke lanes instead (gap register).
|
|
11
|
+
*/
|
|
12
|
+
export const ALLOWLIST = [];
|
|
13
|
+
export const COMMAND_EXEMPTIONS = {};
|
|
14
|
+
export const FILENAME_OVERRIDES = {};
|
|
15
|
+
export const KNOWN_UNFIXTURABLE = {};
|
|
16
|
+
//# sourceMappingURL=fixture-coverage.allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-coverage.allowlist.js","sourceRoot":"","sources":["../../src/__tests__/fixture-coverage.allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,MAAM,CAAC,MAAM,SAAS,GAAsB,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAsB,EAAE,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAsB,EAAE,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-check pass/fail fixture coverage for checks-go (testing gap P0).
|
|
3
|
+
*
|
|
4
|
+
* Every shipped, non-command, fixture-exercisable check must have a clean
|
|
5
|
+
* fixture (0 findings) and a violation fixture (>=1) under a co-located
|
|
6
|
+
* `__fixtures__/<slug>/` directory next to the check's source. The ALLOWLIST is
|
|
7
|
+
* empty, so the ratchet is live: a new uncovered check fails this test. Command
|
|
8
|
+
* checks live in COMMAND_EXEMPTIONS; structurally un-exercisable checks live in
|
|
9
|
+
* KNOWN_UNFIXTURABLE. The harness runs each check in-process via the engine's
|
|
10
|
+
* internal coverage helpers.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=fixture-coverage.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-coverage.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/fixture-coverage.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-check pass/fail fixture coverage for checks-go (testing gap P0).
|
|
3
|
+
*
|
|
4
|
+
* Every shipped, non-command, fixture-exercisable check must have a clean
|
|
5
|
+
* fixture (0 findings) and a violation fixture (>=1) under a co-located
|
|
6
|
+
* `__fixtures__/<slug>/` directory next to the check's source. The ALLOWLIST is
|
|
7
|
+
* empty, so the ratchet is live: a new uncovered check fails this test. Command
|
|
8
|
+
* checks live in COMMAND_EXEMPTIONS; structurally un-exercisable checks live in
|
|
9
|
+
* KNOWN_UNFIXTURABLE. The harness runs each check in-process via the engine's
|
|
10
|
+
* internal coverage helpers.
|
|
11
|
+
*/
|
|
12
|
+
import { dirname, join } from 'node:path';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { planCoverageCases, runCheckOnFixture, validateBookkeeping, } from '@opensip-cli/test-support';
|
|
15
|
+
import { describe, expect, it } from 'vitest';
|
|
16
|
+
import { checks } from '../index.js';
|
|
17
|
+
import { ALLOWLIST, COMMAND_EXEMPTIONS, FILENAME_OVERRIDES, KNOWN_UNFIXTURABLE, } from './fixture-coverage.allowlist.js';
|
|
18
|
+
const PACK_SRC = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
19
|
+
const config = {
|
|
20
|
+
packName: 'checks-go',
|
|
21
|
+
checks,
|
|
22
|
+
allowlist: ALLOWLIST,
|
|
23
|
+
commandExemptions: COMMAND_EXEMPTIONS,
|
|
24
|
+
knownUnfixturable: KNOWN_UNFIXTURABLE,
|
|
25
|
+
filenameOverrides: FILENAME_OVERRIDES,
|
|
26
|
+
};
|
|
27
|
+
const cases = await planCoverageCases(config, PACK_SRC);
|
|
28
|
+
describe('checks-go · fixture-coverage bookkeeping', () => {
|
|
29
|
+
it('config is self-consistent (allowlist empty, exemptions valid)', () => {
|
|
30
|
+
expect(validateBookkeeping(config)).toEqual([]);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('checks-go · fixture-coverage', () => {
|
|
34
|
+
if (cases.length === 0) {
|
|
35
|
+
// No fixturable checks (e.g. an all-command pack): assert every shipped
|
|
36
|
+
// check is accounted for by an exemption rather than silently uncovered.
|
|
37
|
+
it('every shipped check is exempted or allowlisted', () => {
|
|
38
|
+
const accounted = ALLOWLIST.length +
|
|
39
|
+
Object.keys(COMMAND_EXEMPTIONS).length +
|
|
40
|
+
Object.keys(KNOWN_UNFIXTURABLE).length;
|
|
41
|
+
expect(accounted).toBeGreaterThan(0);
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
it.each(cases)('$label', async (testCase) => {
|
|
46
|
+
if (!testCase.fixture)
|
|
47
|
+
expect.fail(testCase.missingHint);
|
|
48
|
+
const run = await runCheckOnFixture(testCase.check, testCase.fixture);
|
|
49
|
+
if (testCase.variant === 'clean') {
|
|
50
|
+
expect(run.findings, `clean fixture for '${testCase.slug}' must produce 0 findings`).toHaveLength(0);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
expect(run.findings.length, `violation fixture for '${testCase.slug}' must produce >=1 finding`).toBeGreaterThanOrEqual(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=fixture-coverage.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-coverage.test.js","sourceRoot":"","sources":["../../src/__tests__/fixture-coverage.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAErE,MAAM,MAAM,GAAmB;IAC7B,QAAQ,EAAE,WAAW;IACrB,MAAM;IACN,SAAS,EAAE,SAAS;IACpB,iBAAiB,EAAE,kBAAkB;IACrC,iBAAiB,EAAE,kBAAkB;IACrC,iBAAiB,EAAE,kBAAkB;CACtC,CAAC;AAEF,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAExD,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ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.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { analyzeFmtPrint } from '../checks/no-fmt-print.js';
|
|
3
|
+
describe('analyzeFmtPrint', () => {
|
|
4
|
+
it('flags fmt.Println', () => {
|
|
5
|
+
const violations = analyzeFmtPrint('fmt.Println("hi")');
|
|
6
|
+
expect(violations.length).toBe(1);
|
|
7
|
+
expect(violations[0]?.message).toContain('fmt.Println');
|
|
8
|
+
expect(violations[0]?.severity).toBe('warning');
|
|
9
|
+
expect(violations[0]?.line).toBe(1);
|
|
10
|
+
});
|
|
11
|
+
it('flags fmt.Printf', () => {
|
|
12
|
+
const violations = analyzeFmtPrint('fmt.Printf("%d", n)');
|
|
13
|
+
expect(violations.length).toBe(1);
|
|
14
|
+
expect(violations[0]?.message).toContain('fmt.Printf');
|
|
15
|
+
expect(violations[0]?.line).toBe(1);
|
|
16
|
+
});
|
|
17
|
+
it('flags fmt.Print', () => {
|
|
18
|
+
const violations = analyzeFmtPrint('fmt.Print(x)');
|
|
19
|
+
expect(violations.length).toBe(1);
|
|
20
|
+
expect(violations[0]?.message).toContain('fmt.Print');
|
|
21
|
+
expect(violations[0]?.line).toBe(1);
|
|
22
|
+
});
|
|
23
|
+
it('does not flag fmt.Sprintf (different method)', () => {
|
|
24
|
+
const violations = analyzeFmtPrint('s := fmt.Sprintf("%d", n)');
|
|
25
|
+
expect(violations.length).toBe(0);
|
|
26
|
+
});
|
|
27
|
+
it('does not flag myfmt.Println (different package)', () => {
|
|
28
|
+
const violations = analyzeFmtPrint('myfmt.Println("hi")');
|
|
29
|
+
expect(violations.length).toBe(0);
|
|
30
|
+
});
|
|
31
|
+
it('reports correct line numbers across multiple matches', () => {
|
|
32
|
+
const src = `package main
|
|
33
|
+
|
|
34
|
+
func main() {
|
|
35
|
+
fmt.Println("first")
|
|
36
|
+
x := 1
|
|
37
|
+
fmt.Printf("%d", x)
|
|
38
|
+
fmt.Print("third")
|
|
39
|
+
}`;
|
|
40
|
+
const violations = analyzeFmtPrint(src);
|
|
41
|
+
expect(violations.length).toBe(3);
|
|
42
|
+
expect(violations[0]?.line).toBe(4);
|
|
43
|
+
expect(violations[1]?.line).toBe(6);
|
|
44
|
+
expect(violations[2]?.line).toBe(7);
|
|
45
|
+
});
|
|
46
|
+
it('flags multiple occurrences on a single line', () => {
|
|
47
|
+
const violations = analyzeFmtPrint('fmt.Print(a); fmt.Println(b)');
|
|
48
|
+
expect(violations.length).toBe(2);
|
|
49
|
+
});
|
|
50
|
+
it('does not flag fmt.Sprint or fmt.Errorf', () => {
|
|
51
|
+
expect(analyzeFmtPrint('fmt.Sprint(a)')).toHaveLength(0);
|
|
52
|
+
expect(analyzeFmtPrint('fmt.Errorf("e")')).toHaveLength(0);
|
|
53
|
+
});
|
|
54
|
+
it('does not flag method-style Print on other receivers', () => {
|
|
55
|
+
expect(analyzeFmtPrint('logger.Print(a)')).toHaveLength(0);
|
|
56
|
+
});
|
|
57
|
+
it('returns an empty list for content without fmt.Print*', () => {
|
|
58
|
+
expect(analyzeFmtPrint('package main\nfunc main() {}')).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=no-fmt-print.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-fmt-print.test.js","sourceRoot":"","sources":["../../src/__tests__/no-fmt-print.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,UAAU,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IA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AAY,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,eAAe,CAAC,8BAA8B,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/run.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Execute the check end-to-end so the closures inside the
|
|
3
|
+
* `defineCheck({...})` config (specifically `analyze`) are invoked.
|
|
4
|
+
*
|
|
5
|
+
* The pure analyzer is exercised by `no-fmt-print.test.ts`. This file's
|
|
6
|
+
* purpose is execution coverage for the un-called closures declared
|
|
7
|
+
* inside the check definition.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { LanguageRegistry, RunScope, runWithScope } from '@opensip-cli/core';
|
|
13
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
14
|
+
import { noFmtPrint } from '../checks/no-fmt-print.js';
|
|
15
|
+
// applyContentFilter resolves the file's adapter via `currentScope()?.languages`
|
|
16
|
+
// (default registry global was removed in T1 cleanup). With no adapter
|
|
17
|
+
// registered for `.go`, applyContentFilter falls through to raw content.
|
|
18
|
+
// Wrap the call in an empty scope so dispatch reaches that no-adapter branch.
|
|
19
|
+
const emptyScope = new RunScope({ languages: new LanguageRegistry() });
|
|
20
|
+
let cwd;
|
|
21
|
+
let target;
|
|
22
|
+
beforeAll(() => {
|
|
23
|
+
cwd = mkdtempSync(join(tmpdir(), 'opensip-checks-go-cov-'));
|
|
24
|
+
target = join(cwd, 'main.go');
|
|
25
|
+
writeFileSync(target, [
|
|
26
|
+
'package main',
|
|
27
|
+
'',
|
|
28
|
+
'import "fmt"',
|
|
29
|
+
'',
|
|
30
|
+
'func main() {',
|
|
31
|
+
'\tfmt.Println("hello")',
|
|
32
|
+
'}',
|
|
33
|
+
'',
|
|
34
|
+
].join('\n'));
|
|
35
|
+
});
|
|
36
|
+
afterAll(() => {
|
|
37
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
38
|
+
});
|
|
39
|
+
describe('noFmtPrint.run() execution coverage', () => {
|
|
40
|
+
it('runs end-to-end against a Go fixture with an fmt.Println call', async () => {
|
|
41
|
+
const result = await runWithScope(emptyScope, () => noFmtPrint.run(cwd, { targetFiles: [target] }));
|
|
42
|
+
expect(result).toBeDefined();
|
|
43
|
+
expect(Array.isArray(result.signals)).toBe(true);
|
|
44
|
+
expect(typeof result.errors).toBe('number');
|
|
45
|
+
expect(typeof result.warnings).toBe('number');
|
|
46
|
+
// The fixture contains exactly one fmt.Println — at minimum one signal.
|
|
47
|
+
expect(result.signals.length).toBeGreaterThanOrEqual(1);
|
|
48
|
+
});
|
|
49
|
+
it('exposes a stable check config (slug/analysisMode/tags)', () => {
|
|
50
|
+
expect(noFmtPrint.config.slug).toBe('go-no-fmt-print');
|
|
51
|
+
expect(noFmtPrint.config.analysisMode).toBe('analyze');
|
|
52
|
+
expect(noFmtPrint.config.tags).toContain('go');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=run.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.test.js","sourceRoot":"","sources":["../../src/__tests__/run.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OA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AAM,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,CACjD,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAC/C,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,wEAAwE;QACxE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Flag direct fmt.Print/Println/Printf calls.
|
|
3
|
+
*
|
|
4
|
+
* fmt.Print* writes unstructured output to stdout, bypassing the
|
|
5
|
+
* structured logger. Production Go services should use a logger
|
|
6
|
+
* (slog, zap, zerolog, etc.) so log records carry context, levels,
|
|
7
|
+
* and machine-parseable fields.
|
|
8
|
+
*
|
|
9
|
+
* Uses the language adapter's `strip-strings-and-comments` filter so
|
|
10
|
+
* the literal string `"fmt.Println("` inside a doc-string or comment
|
|
11
|
+
* doesn't false-fire.
|
|
12
|
+
*/
|
|
13
|
+
import { type CheckViolation } from '@opensip-cli/fitness';
|
|
14
|
+
/**
|
|
15
|
+
* Pure analysis function. Exported so unit tests can exercise the
|
|
16
|
+
* detection logic without standing up the full Check framework
|
|
17
|
+
* (defineCheck wraps `analyze` into an `execute` closure that
|
|
18
|
+
* requires an ExecutionContext to invoke).
|
|
19
|
+
*/
|
|
20
|
+
export declare function analyzeFmtPrint(content: string): CheckViolation[];
|
|
21
|
+
export declare const noFmtPrint: import("@opensip-cli/fitness").Check;
|
|
22
|
+
//# sourceMappingURL=no-fmt-print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-fmt-print.d.ts","sourceRoot":"","sources":["../../src/checks/no-fmt-print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIxE;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAkBjE;AAED,eAAO,MAAM,UAAU,sCAUrB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Flag direct fmt.Print/Println/Printf calls.
|
|
3
|
+
*
|
|
4
|
+
* fmt.Print* writes unstructured output to stdout, bypassing the
|
|
5
|
+
* structured logger. Production Go services should use a logger
|
|
6
|
+
* (slog, zap, zerolog, etc.) so log records carry context, levels,
|
|
7
|
+
* and machine-parseable fields.
|
|
8
|
+
*
|
|
9
|
+
* Uses the language adapter's `strip-strings-and-comments` filter so
|
|
10
|
+
* the literal string `"fmt.Println("` inside a doc-string or comment
|
|
11
|
+
* doesn't false-fire.
|
|
12
|
+
*/
|
|
13
|
+
import { defineCheck } from '@opensip-cli/fitness';
|
|
14
|
+
const FMT_PRINT_PATTERN = /\bfmt\.(Print|Println|Printf)\s*\(/g;
|
|
15
|
+
/**
|
|
16
|
+
* Pure analysis function. Exported so unit tests can exercise the
|
|
17
|
+
* detection logic without standing up the full Check framework
|
|
18
|
+
* (defineCheck wraps `analyze` into an `execute` closure that
|
|
19
|
+
* requires an ExecutionContext to invoke).
|
|
20
|
+
*/
|
|
21
|
+
export function analyzeFmtPrint(content) {
|
|
22
|
+
const violations = [];
|
|
23
|
+
const lines = content.split('\n');
|
|
24
|
+
for (const [i, line_] of lines.entries()) {
|
|
25
|
+
const line = line_;
|
|
26
|
+
let match;
|
|
27
|
+
FMT_PRINT_PATTERN.lastIndex = 0;
|
|
28
|
+
while ((match = FMT_PRINT_PATTERN.exec(line)) !== null) {
|
|
29
|
+
const method = match[1];
|
|
30
|
+
violations.push({
|
|
31
|
+
message: `fmt.${method} bypasses the structured logger and shouldn't ship`,
|
|
32
|
+
severity: 'warning',
|
|
33
|
+
line: i + 1,
|
|
34
|
+
suggestion: 'Use the structured logger (slog, zap, zerolog) instead of fmt.Print*',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return violations;
|
|
39
|
+
}
|
|
40
|
+
export const noFmtPrint = defineCheck({
|
|
41
|
+
id: '438e1324-0a85-4c21-a405-79bb12cfcf6e',
|
|
42
|
+
slug: 'go-no-fmt-print',
|
|
43
|
+
description: "fmt.Print/Println/Printf bypass the structured logger and shouldn't ship",
|
|
44
|
+
scope: { languages: ['go'], concerns: [] },
|
|
45
|
+
tags: ['quality', 'observability', 'go'],
|
|
46
|
+
// strip-strings-and-comments so a literal "fmt.Println(" embedded in a
|
|
47
|
+
// docstring or comment does not false-fire.
|
|
48
|
+
contentFilter: 'strip-strings-and-comments',
|
|
49
|
+
analyze: (content) => analyzeFmtPrint(content),
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=no-fmt-print.js.map
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AAI,CAAC;IACxC,uEAAuE;IACvE,4CAA4C;IAC5C,aAAa,EAAE,4BAA4B;IAC3C,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;CAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display metadata for Go fitness checks.
|
|
3
|
+
*
|
|
4
|
+
* Maps each check slug to its [icon, displayName] tuple for CLI/report
|
|
5
|
+
* rendering. Keys must match the `slug` of the corresponding check.
|
|
6
|
+
*/
|
|
7
|
+
import type { CheckDisplayEntry } from '@opensip-cli/fitness';
|
|
8
|
+
export declare const checkDisplay: Readonly<Record<string, CheckDisplayEntry>>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAEpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,YAAY,GAAgD;IACvE,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC;CACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,wCAAgD,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyCheckDisplay } from '@opensip-cli/fitness';
|
|
2
|
+
import { noFmtPrint } from './checks/no-fmt-print.js';
|
|
3
|
+
import { checkDisplay } from './display/index.js';
|
|
4
|
+
// Display (icon + name) is folded ONTO each check from this pack's `checkDisplay`
|
|
5
|
+
// authoring map (§5.3) — display travels on `check.config`, no separate export.
|
|
6
|
+
export const checks = applyCheckDisplay([noFmtPrint], checkDisplay);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,kFAAkF;AAClF,gFAAgF;AAChF,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAC,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opensip-cli/checks-go",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Go fitness checks for opensip-cli",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"opensip-cli",
|
|
8
|
+
"static-analysis",
|
|
9
|
+
"code-quality",
|
|
10
|
+
"fitness-checks",
|
|
11
|
+
"linting",
|
|
12
|
+
"go",
|
|
13
|
+
"golang"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/opensip-ai/opensip-cli.git",
|
|
18
|
+
"directory": "packages/fitness/checks-go"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/opensip-ai/opensip-cli",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/opensip-ai/opensip-cli/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"opensipTools": {
|
|
26
|
+
"kind": "fit-pack"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"NOTICE"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@opensip-cli/fitness": "0.1.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^24.13.2",
|
|
43
|
+
"vitest": "^4.1.8",
|
|
44
|
+
"@opensip-cli/test-support": "0.1.0",
|
|
45
|
+
"@opensip-cli/core": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc",
|
|
49
|
+
"test": "vitest run --passWithNoTests",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"clean": "rm -rf dist"
|
|
52
|
+
}
|
|
53
|
+
}
|