Class: RosettAi::Comply::Checkers::SpdxHeaderChecker
- Inherits:
-
Object
- Object
- RosettAi::Comply::Checkers::SpdxHeaderChecker
- Defined in:
- lib/rosett_ai/comply/checkers/spdx_header_checker.rb
Overview
SPDX license header compliance checker.
Verifies that all source files contain proper SPDX-License-Identifier headers. Supports Ruby, YAML, JSON, Bash, and Markdown files.
Constant Summary collapse
- SPDX_PATTERN =
/SPDX-License-Identifier:/- HEADER_SCAN_LINES =
10- SOURCE_GLOBS =
[ '**/*.rb', '**/*.yml', '**/*.yaml', '**/*.sh' ].freeze
- SKIP_DIRS =
[ 'vendor', 'node_modules', 'tmp', 'coverage', 'pkg', '.git' ].freeze
Instance Method Summary collapse
-
#check ⇒ Array<Hash>
Runs SPDX header compliance check.
-
#initialize(project_root:, expected_spdx: 'GPL-3.0-only') ⇒ SpdxHeaderChecker
constructor
A new instance of SpdxHeaderChecker.
Constructor Details
#initialize(project_root:, expected_spdx: 'GPL-3.0-only') ⇒ SpdxHeaderChecker
Returns a new instance of SpdxHeaderChecker.
38 39 40 41 |
# File 'lib/rosett_ai/comply/checkers/spdx_header_checker.rb', line 38 def initialize(project_root:, expected_spdx: 'GPL-3.0-only') @project_root = project_root @expected_spdx = expected_spdx end |
Instance Method Details
#check ⇒ Array<Hash>
Runs SPDX header compliance check.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rosett_ai/comply/checkers/spdx_header_checker.rb', line 46 def check files = discover_source_files return [pass_result_no_files] if files.empty? missing = files.reject { |path| spdx_header?(path) } if missing.empty? [pass_result(files.size)] else [warn_result(missing, files.size)] end end |