Skip to content

packagedcode: fix gemspec version constants being stored as-is#4810

Open
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
kumarasantosh:fix/gem-version-constant
Open

packagedcode: fix gemspec version constants being stored as-is#4810
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
kumarasantosh:fix/gem-version-constant

Conversation

@kumarasantosh
Copy link

Fixes #3129

This updates gemspec parsing so unresolved Ruby version constants such as Elasticsearch::API::VERSION, Excon::VERSION, and Faraday::VERSION are not stored as literal package versions.

This adds an is_ruby_version_constant() helper in spec.py that detects these unresolvable constants and sets version to None instead of storing the literal constant string.

When a gemspec uses a Ruby constant for the version field like:
  s.version = Elasticsearch::API::VERSION
  s.version = Faraday::VERSION

scancode was storing the constant name as the version string.
These constants cannot be resolved without executing Ruby code.

Add is_ruby_version_constant() to detect Ruby constant
expressions (containing :: namespace separator or bare
uppercase constant names) and return None for the version
instead of storing an unresolvable constant string.

Also fixes the download_url and api_data_url which were
generating invalid URLs with the constant name embedded.

Fixes aboutcode-org#3129

Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
@kumarasantosh kumarasantosh force-pushed the fix/gem-version-constant branch from 51c853d to f8d1c47 Compare March 13, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect gem version

1 participant