es-spdx-check 0.1.0__tar.gz

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 (46) hide show
  1. es_spdx_check-0.1.0/Cargo.lock +7 -0
  2. es_spdx_check-0.1.0/Cargo.toml +24 -0
  3. es_spdx_check-0.1.0/LICENSE +22 -0
  4. es_spdx_check-0.1.0/PKG-INFO +99 -0
  5. es_spdx_check-0.1.0/README.md +80 -0
  6. es_spdx_check-0.1.0/pyproject.toml +31 -0
  7. es_spdx_check-0.1.0/rustfmt.toml +1 -0
  8. es_spdx_check-0.1.0/src/defs.rs +265 -0
  9. es_spdx_check-0.1.0/src/engine.rs +207 -0
  10. es_spdx_check-0.1.0/src/logger.rs +62 -0
  11. es_spdx_check-0.1.0/src/main.rs +317 -0
  12. es_spdx_check-0.1.0/src/options.rs +649 -0
  13. es_spdx_check-0.1.0/src/process.rs +524 -0
  14. es_spdx_check-0.1.0/src/spdx.rs +811 -0
  15. es_spdx_check-0.1.0/src/util.rs +311 -0
  16. es_spdx_check-0.1.0/support/spdx-license-data.ini +2 -0
  17. es_spdx_check-0.1.0/support/task-full-check.sh +17 -0
  18. es_spdx_check-0.1.0/support/update-spdx-license-data.py +106 -0
  19. es_spdx_check-0.1.0/tests/assets/sample-file-targets.txt +14 -0
  20. es_spdx_check-0.1.0/tests/assets/sample-ignore-patterns.txt +14 -0
  21. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-01.txt +1 -0
  22. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-02.txt +3 -0
  23. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-03.txt +3 -0
  24. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-04.txt +3 -0
  25. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-05.txt +1 -0
  26. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-06.txt +3 -0
  27. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-07.txt +1 -0
  28. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-08.txt +1 -0
  29. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-09.txt +2 -0
  30. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-10.txt +1 -0
  31. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-11.txt +1 -0
  32. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-12.txt +1 -0
  33. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-13.txt +1 -0
  34. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-14.txt +3 -0
  35. es_spdx_check-0.1.0/tests/assets/spdx-check-commented-15.txt +3 -0
  36. es_spdx_check-0.1.0/tests/assets/spdx-check-empty.txt +0 -0
  37. es_spdx_check-0.1.0/tests/assets/spdx-check-invalid-exception.txt +1 -0
  38. es_spdx_check-0.1.0/tests/assets/spdx-check-invalid-license.txt +1 -0
  39. es_spdx_check-0.1.0/tests/assets/spdx-check-missing-key.txt +1 -0
  40. es_spdx_check-0.1.0/tests/assets/spdx-check-missing-value.txt +1 -0
  41. es_spdx_check-0.1.0/tests/assets/spdx-check-shebang.txt +2 -0
  42. es_spdx_check-0.1.0/tests/assets/spdx-check-valid-complex.txt +1 -0
  43. es_spdx_check-0.1.0/tests/assets/spdx-check-valid-custom.txt +1 -0
  44. es_spdx_check-0.1.0/tests/assets/spdx-check-valid-exception.txt +1 -0
  45. es_spdx_check-0.1.0/tests/assets/spdx-check-valid-multiple.txt +1 -0
  46. es_spdx_check-0.1.0/tests/assets/spdx-check-valid-single.txt +1 -0
@@ -0,0 +1,7 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "es-spdx-check"
7
+ version = "0.1.0"
@@ -0,0 +1,24 @@
1
+ # SPDX-License-Identifier: BSD-2-Clause
2
+ # Copyright jdknight
3
+
4
+ [package]
5
+ name = "es-spdx-check"
6
+ description = "Utility to scan source files for valid SPDX license expressions."
7
+ version = "0.1.0"
8
+ edition = "2024"
9
+ license = "BSD-2-Clause"
10
+ repository = "https://github.com/jdknight/es-spdx-check"
11
+
12
+ include = [
13
+ "/src/",
14
+ "/support/",
15
+ "/tests/",
16
+ "/LICENSE",
17
+ "/README.md",
18
+ "/rustfmt.toml",
19
+ ]
20
+ readme = "README.md"
21
+
22
+ [features]
23
+ default = []
24
+ file-name-ref = []
@@ -0,0 +1,22 @@
1
+ Copyright 2026 jdknight
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: es-spdx-check
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Programming Language :: Rust
9
+ Classifier: Topic :: Software Development :: Quality Assurance
10
+ License-File: LICENSE
11
+ Summary: Utility to scan source files for valid SPDX license expressions.
12
+ License-Expression: BSD-2-Clause
13
+ Requires-Python: >=3.7
14
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
+ Project-URL: Download, https://pypi.org/project/es-spdx-check/
16
+ Project-URL: Homepage, https://github.com/jdknight/es-spdx-check
17
+ Project-URL: Source, https://github.com/jdknight/es-spdx-check
18
+
19
+ # es-spdx-check
20
+
21
+ Extremely Simple SPDX Check is a utility which can scan source files and
22
+ report if a valid [SPDX license expression][spdx-license-nfo] is set.
23
+
24
+ ## Installation
25
+
26
+ This tool can be installed using [pip][pip] or [pipx][pipx]:
27
+
28
+ ```shell
29
+ pipx install es-spdx-check
30
+ (or)
31
+ pip install -U es-spdx-check
32
+ (or)
33
+ python -m pip install -U es-spdx-check
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ This tool can be invoked from a command line using:
39
+
40
+ ```shell
41
+ es-spdx-check --help
42
+ ```
43
+
44
+ To scan the working directory:
45
+
46
+ ```shell
47
+ es-spdx-check
48
+ ```
49
+
50
+ To scan a specific directory:
51
+
52
+ ```shell
53
+ es-spdx-check src/
54
+ ```
55
+
56
+ To limit the amount of workers used:
57
+
58
+ ```shell
59
+ es-spdx-check --workers $(nproc --ignore=1)
60
+ ```
61
+
62
+ Users can exclude directories from a scan using `--exclude`:
63
+
64
+ ```shell
65
+ es-spdx-check --exclude tests
66
+ ```
67
+
68
+ The `--include` argument can be used to include any default excluded path.
69
+ If a `.esspdxignore` file exists, it can be used to hint directories to
70
+ exclude or include (`!`-prefixed). For example:
71
+
72
+ ```
73
+ # exclude tests
74
+ tests/
75
+
76
+ # allow checking target directory
77
+ !target/
78
+ ```
79
+
80
+ This tool defines a set of default file names and extensions to scan. If a
81
+ `.esspdxtargets` file exists, it can be used to hint at additional file names
82
+ or extensions to check for; or not checked for (`!`-prefixed). For example:
83
+
84
+ ```
85
+ # perform checks on any ".custom" extension
86
+ .custom
87
+
88
+ # perform checks on file named "CustomFile"
89
+ CustomFile
90
+
91
+ # ignore any scripts
92
+ !.sh
93
+ ```
94
+
95
+
96
+ [pip]: https://pip.pypa.io/
97
+ [pipx]: https://pipx.pypa.io/
98
+ [spdx-license-nfo]: https://spdx.dev/learn/handling-license-info/
99
+
@@ -0,0 +1,80 @@
1
+ # es-spdx-check
2
+
3
+ Extremely Simple SPDX Check is a utility which can scan source files and
4
+ report if a valid [SPDX license expression][spdx-license-nfo] is set.
5
+
6
+ ## Installation
7
+
8
+ This tool can be installed using [pip][pip] or [pipx][pipx]:
9
+
10
+ ```shell
11
+ pipx install es-spdx-check
12
+ (or)
13
+ pip install -U es-spdx-check
14
+ (or)
15
+ python -m pip install -U es-spdx-check
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ This tool can be invoked from a command line using:
21
+
22
+ ```shell
23
+ es-spdx-check --help
24
+ ```
25
+
26
+ To scan the working directory:
27
+
28
+ ```shell
29
+ es-spdx-check
30
+ ```
31
+
32
+ To scan a specific directory:
33
+
34
+ ```shell
35
+ es-spdx-check src/
36
+ ```
37
+
38
+ To limit the amount of workers used:
39
+
40
+ ```shell
41
+ es-spdx-check --workers $(nproc --ignore=1)
42
+ ```
43
+
44
+ Users can exclude directories from a scan using `--exclude`:
45
+
46
+ ```shell
47
+ es-spdx-check --exclude tests
48
+ ```
49
+
50
+ The `--include` argument can be used to include any default excluded path.
51
+ If a `.esspdxignore` file exists, it can be used to hint directories to
52
+ exclude or include (`!`-prefixed). For example:
53
+
54
+ ```
55
+ # exclude tests
56
+ tests/
57
+
58
+ # allow checking target directory
59
+ !target/
60
+ ```
61
+
62
+ This tool defines a set of default file names and extensions to scan. If a
63
+ `.esspdxtargets` file exists, it can be used to hint at additional file names
64
+ or extensions to check for; or not checked for (`!`-prefixed). For example:
65
+
66
+ ```
67
+ # perform checks on any ".custom" extension
68
+ .custom
69
+
70
+ # perform checks on file named "CustomFile"
71
+ CustomFile
72
+
73
+ # ignore any scripts
74
+ !.sh
75
+ ```
76
+
77
+
78
+ [pip]: https://pip.pypa.io/
79
+ [pipx]: https://pipx.pypa.io/
80
+ [spdx-license-nfo]: https://spdx.dev/learn/handling-license-info/
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.9.3,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "es-spdx-check"
7
+ requires-python = ">=3.7"
8
+ readme = 'README.md'
9
+ license = 'BSD-2-Clause'
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Rust",
16
+ "Topic :: Software Development :: Quality Assurance",
17
+ ]
18
+ dynamic = [
19
+ "description",
20
+ "version",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = 'https://github.com/jdknight/es-spdx-check'
25
+ Download = 'https://pypi.org/project/es-spdx-check/'
26
+ Source = 'https://github.com/jdknight/es-spdx-check'
27
+
28
+ [tool.maturin]
29
+ bindings = "bin"
30
+ module-name = "es-spdx-check"
31
+ strip = true
@@ -0,0 +1 @@
1
+ max_width = 80
@@ -0,0 +1,265 @@
1
+ // SPDX-License-Identifier: BSD-2-Clause
2
+ // Copyright jdknight
3
+
4
+ use std::num::NonZeroUsize;
5
+
6
+ /// Version of this utility.
7
+ pub const ESSPDX_VERSION: &str = env!("CARGO_PKG_VERSION");
8
+
9
+ /// Package name of this utility.
10
+ pub const ESSPDX_PKG_NAME: &str = env!("CARGO_PKG_NAME");
11
+
12
+ /// Default number of workers to use if we cannot detect a good processor count.
13
+ pub const DEFAULT_WORKERS: NonZeroUsize = NonZeroUsize::new(4).unwrap();
14
+
15
+ /// Default file extensions to check for SPDX-License-Identifier.
16
+ #[rustfmt::skip]
17
+ pub const DEFAULT_TARGET_EXTENSIONS: &[&str] = &[
18
+ "ada",
19
+ "adb",
20
+ "ads",
21
+ "asm",
22
+ "astro",
23
+ "awk",
24
+ "bat",
25
+ "c",
26
+ "cc",
27
+ "cginc",
28
+ "cjs",
29
+ "clj",
30
+ "cljc",
31
+ "cljs",
32
+ "cmake",
33
+ "cmd",
34
+ "coffee",
35
+ "comp",
36
+ "cpp",
37
+ "cr",
38
+ "cs",
39
+ "cts",
40
+ "cxx",
41
+ "d",
42
+ "dart",
43
+ "el",
44
+ "elm",
45
+ "erl",
46
+ "ex",
47
+ "exs",
48
+ "f",
49
+ "f90",
50
+ "f95",
51
+ "fish",
52
+ "for",
53
+ "frag",
54
+ "fs",
55
+ "fsi",
56
+ "fsx",
57
+ "gleam",
58
+ "glsl",
59
+ "go",
60
+ "gql",
61
+ "gradle",
62
+ "graphql",
63
+ "groovy",
64
+ "h",
65
+ "hcl",
66
+ "hh",
67
+ "hlsl",
68
+ "hpp",
69
+ "hrl",
70
+ "hs",
71
+ "hxx",
72
+ "ino",
73
+ "java",
74
+ "jl",
75
+ "js",
76
+ "jsx",
77
+ "kt",
78
+ "kts",
79
+ "less",
80
+ "lhs",
81
+ "lisp",
82
+ "lua",
83
+ "m",
84
+ "metal",
85
+ "mjs",
86
+ "ml",
87
+ "mli",
88
+ "mm",
89
+ "mts",
90
+ "nim",
91
+ "nix",
92
+ "nu",
93
+ "pas",
94
+ "php",
95
+ "phtml",
96
+ "pl",
97
+ "pm",
98
+ "pp",
99
+ "prisma",
100
+ "proto",
101
+ "ps1",
102
+ "psd1",
103
+ "psm1",
104
+ "pug",
105
+ "py",
106
+ "pyi",
107
+ "pyw",
108
+ "r",
109
+ "rb",
110
+ "rkt",
111
+ "rs",
112
+ "rt",
113
+ "s",
114
+ "sass",
115
+ "scala",
116
+ "scm",
117
+ "scss",
118
+ "sh",
119
+ "sol",
120
+ "sql",
121
+ "styl",
122
+ "sv",
123
+ "svelte",
124
+ "svh",
125
+ "swift",
126
+ "tcl",
127
+ "tf",
128
+ "ts",
129
+ "tsx",
130
+ "v",
131
+ "vala",
132
+ "vb",
133
+ "vert",
134
+ "vhd",
135
+ "vhdl",
136
+ "vue",
137
+ "wat",
138
+ "wgsl",
139
+ "yaml",
140
+ "yml",
141
+ "zig",
142
+ "zsh",
143
+ ];
144
+
145
+ /// Default file names to check for SPDX-License-Identifier.
146
+ #[rustfmt::skip]
147
+ pub const DEFAULT_TARGET_NAMES: &[&str] = &[
148
+ "build",
149
+ "build.bazel",
150
+ "cmakelists.txt",
151
+ "containerfile",
152
+ "dockerfile",
153
+ "justfile",
154
+ "makefile",
155
+ "procfile",
156
+ "rakefile",
157
+ "vagrantfile",
158
+ "workspace",
159
+ ];
160
+
161
+ /// Default list used for directories to exclude/ignore.
162
+ #[rustfmt::skip]
163
+ pub const DEFAULT_EXCLUDE_ENTIRE_LIST: &[&str] = &[
164
+ ".AppleDouble",
165
+ ".angular",
166
+ ".astro",
167
+ ".bzr",
168
+ ".cargo",
169
+ ".cargo-vendor",
170
+ ".cursor",
171
+ ".dart_tool",
172
+ ".git",
173
+ ".gradle",
174
+ ".hg",
175
+ ".idea",
176
+ ".jj",
177
+ ".lore",
178
+ ".mvn",
179
+ ".mypy_cache",
180
+ ".next",
181
+ ".nuxt",
182
+ ".parcel-cache",
183
+ ".pijul",
184
+ ".pytest_cache",
185
+ ".ruff_cache",
186
+ ".svelte-kit",
187
+ ".svn",
188
+ ".terraform",
189
+ ".tox",
190
+ ".turbo",
191
+ ".venv",
192
+ ".vs",
193
+ ".vscode",
194
+ ".xmake",
195
+ "CVS",
196
+ "Debug",
197
+ "LC_MESSAGES",
198
+ "Pods",
199
+ "Release",
200
+ "__pycache__",
201
+ "_build",
202
+ "_tmp",
203
+ "cache",
204
+ "coverage",
205
+ "deps",
206
+ "dist",
207
+ "htmlcov",
208
+ "node_modules",
209
+ "obj",
210
+ "out",
211
+ "output",
212
+ "target",
213
+ "temp",
214
+ "tmp",
215
+ "venv",
216
+ ];
217
+
218
+ /// Default list used for directories to exclude/ignore.
219
+ #[rustfmt::skip]
220
+ pub const DEFAULT_EXCLUDE_PREFIX_LIST: &[&str] = &[
221
+ ".aider.tags.cache.",
222
+ ];
223
+
224
+ /// Default list used for directories to exclude/ignore.
225
+ #[rustfmt::skip]
226
+ pub const DEFAULT_EXCLUDE_SUFFIX_LIST: &[&str] = &[
227
+ ".egg-info",
228
+ ];
229
+
230
+ /// Filename used for an exclude/include file-based configuration.
231
+ pub const ESSPDX_IGNORE_FILENAME: &str = ".esspdxignore";
232
+
233
+ /// Filename used for a extension/names targets via file-based configuration.
234
+ pub const ESSPDX_TARGETS_FILENAME: &str = ".esspdxtargets";
235
+
236
+ /// Metadata key for a SPDX license identifier.
237
+ pub const SPDX_LICENSE_IDENTIFIER: &str = "SPDX-License-Identifier:";
238
+
239
+ // ============================================================================
240
+ // Tests
241
+ // ============================================================================
242
+
243
+ #[cfg(test)]
244
+ mod tests {
245
+ use super::*;
246
+
247
+ #[test]
248
+ fn default_target_extensions_have_no_dot() {
249
+ assert!(
250
+ DEFAULT_TARGET_EXTENSIONS
251
+ .iter()
252
+ .all(|p| !p.starts_with('.'))
253
+ );
254
+ }
255
+
256
+ #[test]
257
+ fn default_target_patterns_are_lowercase() {
258
+ assert!(
259
+ DEFAULT_TARGET_EXTENSIONS
260
+ .iter()
261
+ .all(|p| *p == p.to_lowercase())
262
+ );
263
+ assert!(DEFAULT_TARGET_NAMES.iter().all(|p| *p == p.to_lowercase()));
264
+ }
265
+ }