From 4eca0ec15dc6266afa48b74b3742278351246eb8 Mon Sep 17 00:00:00 2001 From: Parv Mital Date: Tue, 27 Apr 2021 11:04:19 -0400 Subject: [PATCH] [FIXED] Ignore packages with nil modules Signed-off-by: Julia Pu --- lib/license_finder/package_managers/go_modules.rb | 4 ++-- spec/lib/license_finder/package_managers/go_modules_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/license_finder/package_managers/go_modules.rb b/lib/license_finder/package_managers/go_modules.rb index 0ee8b0d2..68422e0c 100644 --- a/lib/license_finder/package_managers/go_modules.rb +++ b/lib/license_finder/package_managers/go_modules.rb @@ -34,7 +34,7 @@ def packages_info # * Only list dependencies (packages not listed in the project directory) # (.DepOnly) # * Ignore packages that have nil modules - # (ne .Module nil) + # (.Module) # * Ignore standard library packages # (not .Standard) # * Replacement modules are respected @@ -42,7 +42,7 @@ def packages_info # * Module cache directory or (vendored) package directory # (or $mod.Dir .Dir) format_str = \ - '{{ if and (.DepOnly) (ne .Module nil) (not .Standard) }}'\ + '{{ if and (.DepOnly) (.Module) (not .Standard) }}'\ '{{ $mod := (or .Module.Replace .Module) }}'\ '{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}'\ '{{ end }}' diff --git a/spec/lib/license_finder/package_managers/go_modules_spec.rb b/spec/lib/license_finder/package_managers/go_modules_spec.rb index d9f5d40f..92ea19e6 100644 --- a/spec/lib/license_finder/package_managers/go_modules_spec.rb +++ b/spec/lib/license_finder/package_managers/go_modules_spec.rb @@ -10,7 +10,7 @@ module LicenseFinder let(:src_path) { '/workspace/code' } let(:mod_path) { "#{src_path}/go.mod" } let(:vendor_path) { "#{src_path}/vendor" } - let(:go_list_format) { '{{ if and (.DepOnly) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' } + let(:go_list_format) { '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' } let(:go_list_string) do "foo,,/workspace/code/\ngopkg.in/check.v1,v0.0.0-20161208181325-20d25e280405,"\ "/workspace/LicenseFinder/features/fixtures/go_modules/vendor/gopkg.in/check.v1\n"\