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 =
Returns Regex matching valid SPDX license identifier lines.
/SPDX-License-Identifier:/- HEADER_SCAN_LINES =
Returns Number of lines to scan for SPDX headers.
10- SOURCE_GLOBS =
Returns Glob patterns for source files requiring SPDX headers.
[ '**/*.rb', '**/*.yml', '**/*.yaml', '**/*.sh' ].freeze
- SKIP_DIRS =
Returns Directory names excluded from SPDX header scanning.
[ '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.
42 43 44 45 |
# File 'lib/rosett_ai/comply/checkers/spdx_header_checker.rb', line 42 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.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rosett_ai/comply/checkers/spdx_header_checker.rb', line 50 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 |