feat: improve license checks #232
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant updates to the license validation logic in the
pkg/linters/module/rules
package. The changes enhance the ability to differentiate between Community Edition (CE) and Enterprise Edition (EE) licenses, streamline file filtering, and improve modularity by removing unused imports and redundant code.License Validation Enhancements:
LicenseType
enumeration to distinguish between CE and EE licenses, and implemented thegetLicenseType
function to determine the expected license type based on file paths. Files in directories starting with "ee" are expected to have an EE license, while others default to a CE license. (pkg/linters/module/rules/license_library.go
, pkg/linters/module/rules/license_library.goL51-R80)EELicenseRe
, to validate EE license headers. Updated thecheckFileCopyright
function to validate the license type based on the file path and provide detailed error messages when mismatches occur. (pkg/linters/module/rules/license_library.go
, [1] [2]Code Simplification:
license.go
to clean up the codebase. (pkg/linters/module/rules/license.go
, pkg/linters/module/rules/license.goL22-L25)filterFiles
function, relying instead on existing regular expressions for file matching. (pkg/linters/module/rules/license.go
, pkg/linters/module/rules/license.goL77-L84)Additional Improvements:
CELicenseRe
regular expression to account for optional "C" in "Flant C?JSC" to improve flexibility in CE license validation. (pkg/linters/module/rules/license_library.go
, pkg/linters/module/rules/license_library.goR23-R28)