license_finder 3.0.4 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +29 -2
  4. data/CONTRIBUTING.md +5 -1
  5. data/Dockerfile +33 -10
  6. data/Gemfile +2 -2
  7. data/README.md +27 -5
  8. data/Rakefile +15 -21
  9. data/ci/pipelines/pipeline.yml.erb +40 -6
  10. data/ci/pipelines/release.yml +11 -5
  11. data/ci/scripts/containerize-tests.sh +16 -0
  12. data/ci/scripts/run-rubocop.sh +8 -0
  13. data/ci/scripts/run-tests.sh +22 -0
  14. data/ci/scripts/test.ps1 +81 -0
  15. data/ci/tasks/build-windows.yml +6 -0
  16. data/ci/tasks/build.yml +2 -2
  17. data/ci/tasks/rubocop.yml +13 -0
  18. data/features/features/cli/cli_spec.rb +8 -8
  19. data/features/features/configure/add_dependencies_spec.rb +7 -7
  20. data/features/features/configure/approve_dependencies_spec.rb +15 -15
  21. data/features/features/configure/assign_licenses_spec.rb +4 -4
  22. data/features/features/configure/blacklist_licenses_spec.rb +3 -3
  23. data/features/features/configure/ignore_dependencies_spec.rb +3 -3
  24. data/features/features/configure/ignore_groups_spec.rb +4 -4
  25. data/features/features/configure/name_project_spec.rb +4 -4
  26. data/features/features/configure/set_project_path_spec.rb +2 -2
  27. data/features/features/configure/whitelist_licenses_spec.rb +4 -4
  28. data/features/features/package_managers/bower_spec.rb +3 -3
  29. data/features/features/package_managers/carthage_spec.rb +14 -0
  30. data/features/features/package_managers/cocoapods_spec.rb +3 -3
  31. data/features/features/package_managers/conan_spec.rb +11 -0
  32. data/features/features/package_managers/dep_spec.rb +15 -0
  33. data/features/features/package_managers/glide_spec.rb +14 -0
  34. data/features/features/package_managers/govendor_spec.rb +15 -0
  35. data/features/features/package_managers/gradle_spec.rb +1 -1
  36. data/features/features/package_managers/gvt_spec.rb +14 -0
  37. data/features/features/package_managers/maven_spec.rb +2 -3
  38. data/features/features/package_managers/mix_spec.rb +16 -0
  39. data/features/features/package_managers/npm_spec.rb +3 -3
  40. data/features/features/package_managers/nuget_spec.rb +4 -4
  41. data/features/features/package_managers/pip_spec.rb +2 -2
  42. data/features/features/package_managers/rebar_spec.rb +3 -3
  43. data/features/features/package_managers/yarn_spec.rb +14 -0
  44. data/features/features/report/composite_spec.rb +1 -1
  45. data/features/features/report/csv_spec.rb +3 -3
  46. data/features/features/report/diff_spec.rb +20 -10
  47. data/features/features/report/html_spec.rb +10 -10
  48. data/features/features/report/subproject_spec.rb +15 -4
  49. data/features/fixtures/Cartfile +1 -0
  50. data/features/fixtures/Podfile +1 -1
  51. data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
  52. data/features/fixtures/build.gradle +5 -15
  53. data/features/fixtures/conanfile.txt +11 -0
  54. data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
  55. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
  56. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
  57. data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
  58. data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
  59. data/features/fixtures/gopath_glide/src/glide.lock +9 -0
  60. data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
  61. data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
  62. data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
  63. data/features/fixtures/gradle-wrapper/build.gradle +5 -15
  64. data/features/fixtures/gradle-wrapper/gradlew +6 -1
  65. data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
  66. data/features/fixtures/mix.exs +22 -0
  67. data/features/fixtures/multi-module-gradle/build.gradle +7 -15
  68. data/features/fixtures/single-module-gradle/build.gradle +5 -15
  69. data/features/support/testing_dsl.rb +155 -43
  70. data/lib/license_finder.rb +4 -3
  71. data/lib/license_finder/cli.rb +0 -3
  72. data/lib/license_finder/cli/approvals.rb +3 -3
  73. data/lib/license_finder/cli/base.rb +11 -8
  74. data/lib/license_finder/cli/blacklist.rb +7 -7
  75. data/lib/license_finder/cli/dependencies.rb +8 -8
  76. data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
  77. data/lib/license_finder/cli/ignored_groups.rb +4 -4
  78. data/lib/license_finder/cli/licenses.rb +2 -2
  79. data/lib/license_finder/cli/main.rb +59 -39
  80. data/lib/license_finder/cli/makes_decisions.rb +2 -2
  81. data/lib/license_finder/cli/patched_thor.rb +6 -7
  82. data/lib/license_finder/cli/project_name.rb +5 -6
  83. data/lib/license_finder/cli/whitelist.rb +7 -7
  84. data/lib/license_finder/configuration.rb +15 -4
  85. data/lib/license_finder/core.rb +20 -4
  86. data/lib/license_finder/decision_applier.rb +0 -1
  87. data/lib/license_finder/decisions.rb +12 -14
  88. data/lib/license_finder/diff.rb +33 -31
  89. data/lib/license_finder/license.rb +13 -9
  90. data/lib/license_finder/license/definitions.rb +55 -55
  91. data/lib/license_finder/license/none_matcher.rb +1 -1
  92. data/lib/license_finder/license/template.rb +1 -1
  93. data/lib/license_finder/license/text.rb +0 -1
  94. data/lib/license_finder/license_aggregator.rb +1 -0
  95. data/lib/license_finder/logger.rb +18 -61
  96. data/lib/license_finder/package.rb +25 -11
  97. data/lib/license_finder/package_delta.rb +3 -6
  98. data/lib/license_finder/package_manager.rb +77 -34
  99. data/lib/license_finder/package_managers/bower.rb +8 -8
  100. data/lib/license_finder/package_managers/bower_package.rb +12 -12
  101. data/lib/license_finder/package_managers/bundler.rb +21 -9
  102. data/lib/license_finder/package_managers/bundler_package.rb +1 -1
  103. data/lib/license_finder/package_managers/carthage.rb +66 -0
  104. data/lib/license_finder/package_managers/carthage_package.rb +16 -0
  105. data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
  106. data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
  107. data/lib/license_finder/package_managers/conan.rb +26 -0
  108. data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
  109. data/lib/license_finder/package_managers/conan_package.rb +17 -0
  110. data/lib/license_finder/package_managers/dep.rb +33 -0
  111. data/lib/license_finder/package_managers/glide.rb +30 -0
  112. data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
  113. data/lib/license_finder/package_managers/go_dep.rb +15 -12
  114. data/lib/license_finder/package_managers/go_package.rb +15 -13
  115. data/lib/license_finder/package_managers/go_workspace.rb +39 -34
  116. data/lib/license_finder/package_managers/govendor.rb +32 -0
  117. data/lib/license_finder/package_managers/gradle.rb +16 -16
  118. data/lib/license_finder/package_managers/gradle_package.rb +8 -8
  119. data/lib/license_finder/package_managers/gvt.rb +61 -0
  120. data/lib/license_finder/package_managers/maven.rb +17 -18
  121. data/lib/license_finder/package_managers/maven_package.rb +4 -6
  122. data/lib/license_finder/package_managers/merged_package.rb +25 -2
  123. data/lib/license_finder/package_managers/mix.rb +51 -0
  124. data/lib/license_finder/package_managers/mix_package.rb +7 -0
  125. data/lib/license_finder/package_managers/npm.rb +8 -32
  126. data/lib/license_finder/package_managers/npm_package.rb +51 -48
  127. data/lib/license_finder/package_managers/nuget.rb +30 -40
  128. data/lib/license_finder/package_managers/pip.rb +11 -11
  129. data/lib/license_finder/package_managers/pip_package.rb +8 -8
  130. data/lib/license_finder/package_managers/rebar.rb +11 -11
  131. data/lib/license_finder/package_managers/yarn.rb +62 -0
  132. data/lib/license_finder/packages/activation.rb +2 -2
  133. data/lib/license_finder/packages/license_files.rb +6 -6
  134. data/lib/license_finder/packages/licensing.rb +8 -10
  135. data/lib/license_finder/packages/manual_package.rb +2 -2
  136. data/lib/license_finder/project_finder.rb +6 -5
  137. data/lib/license_finder/report.rb +1 -0
  138. data/lib/license_finder/reports/csv_report.rb +4 -4
  139. data/lib/license_finder/reports/diff_report.rb +2 -2
  140. data/lib/license_finder/reports/erb_report.rb +2 -4
  141. data/lib/license_finder/reports/html_report.rb +2 -2
  142. data/lib/license_finder/reports/markdown_report.rb +1 -1
  143. data/lib/license_finder/reports/merged_report.rb +1 -1
  144. data/lib/license_finder/reports/text_report.rb +3 -5
  145. data/lib/license_finder/shared_helpers/cmd.rb +11 -0
  146. data/lib/license_finder/version.rb +1 -1
  147. data/license_finder-2.1.2.gem +0 -0
  148. data/license_finder.gemspec +38 -38
  149. metadata +84 -118
  150. data/ci/scripts/test.sh +0 -26
  151. data/ci/tasks/create-source-archives.yml +0 -23
  152. data/spec/dummy_app/Gemfile +0 -6
  153. data/spec/fixtures/all_pms/.envrc +0 -1
  154. data/spec/fixtures/all_pms/.nuget/.keep +0 -0
  155. data/spec/fixtures/all_pms/Gemfile +0 -0
  156. data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
  157. data/spec/fixtures/all_pms/Podfile +0 -0
  158. data/spec/fixtures/all_pms/bower.json +0 -0
  159. data/spec/fixtures/all_pms/build.gradle +0 -0
  160. data/spec/fixtures/all_pms/package.json +0 -0
  161. data/spec/fixtures/all_pms/pom.xml +0 -0
  162. data/spec/fixtures/all_pms/rebar.config +0 -0
  163. data/spec/fixtures/all_pms/requirements.txt +0 -0
  164. data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
  165. data/spec/fixtures/composite/Gemfile +0 -0
  166. data/spec/fixtures/composite/nested_project/.envrc +0 -8
  167. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
  168. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
  169. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
  170. data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
  171. data/spec/fixtures/composite/project1/Gemfile +0 -0
  172. data/spec/fixtures/composite/project2/package.json +0 -0
  173. data/spec/fixtures/config/license_finder.yml +0 -5
  174. data/spec/fixtures/license_directory/COPYING +0 -1
  175. data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
  176. data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
  177. data/spec/fixtures/license_names/COPYING.txt +0 -1
  178. data/spec/fixtures/license_names/LICENSE +0 -1
  179. data/spec/fixtures/license_names/Licence.rdoc +0 -1
  180. data/spec/fixtures/license_names/Mit-License +0 -1
  181. data/spec/fixtures/license_names/README.rdoc +0 -1
  182. data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
  183. data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
  184. data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
  185. data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
  186. data/spec/fixtures/npm-circular-licenses/package.json +0 -23
  187. data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
  188. data/spec/fixtures/npm-licenses-string/package.json +0 -23
  189. data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
  190. data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
  191. data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
  192. data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
  193. data/spec/fixtures/utf8_gem/README +0 -210
  194. data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
  195. data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
  196. data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
  197. data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
  198. data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
  199. data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
  200. data/spec/lib/license_finder/cli/main_spec.rb +0 -243
  201. data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
  202. data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
  203. data/spec/lib/license_finder/configuration_spec.rb +0 -115
  204. data/spec/lib/license_finder/core_spec.rb +0 -54
  205. data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
  206. data/spec/lib/license_finder/decisions_spec.rb +0 -408
  207. data/spec/lib/license_finder/diff_spec.rb +0 -129
  208. data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
  209. data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
  210. data/spec/lib/license_finder/license_spec.rb +0 -106
  211. data/spec/lib/license_finder/package_delta_spec.rb +0 -18
  212. data/spec/lib/license_finder/package_manager_spec.rb +0 -62
  213. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
  214. data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
  215. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
  216. data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
  217. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
  218. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
  219. data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
  220. data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
  221. data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
  222. data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
  223. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
  224. data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
  225. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
  226. data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
  227. data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
  228. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
  229. data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
  230. data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
  231. data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
  232. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
  233. data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
  234. data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
  235. data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
  236. data/spec/lib/license_finder/package_spec.rb +0 -179
  237. data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
  238. data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
  239. data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
  240. data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
  241. data/spec/lib/license_finder/project_finder_spec.rb +0 -33
  242. data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
  243. data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
  244. data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
  245. data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
  246. data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
  247. data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
  248. data/spec/spec_helper.rb +0 -27
  249. data/spec/support/shared_examples_for_package_manager.rb +0 -52
  250. data/spec/support/stdout_helpers.rb +0 -31
  251. data/spec/support/test_fixtures.rb +0 -7
@@ -3,9 +3,9 @@ require 'httparty'
3
3
 
4
4
  module LicenseFinder
5
5
  class Pip < PackageManager
6
- def initialize(options={})
6
+ def initialize(options = {})
7
7
  super
8
- @requirements_path = options[:pip_requirements_path] || 'requirements.txt'
8
+ @requirements_path = options[:pip_requirements_path] || Pathname('requirements.txt')
9
9
  end
10
10
 
11
11
  def current_packages
@@ -16,36 +16,36 @@ module LicenseFinder
16
16
  pypi_def(name, version),
17
17
  logger: logger,
18
18
  children: children,
19
- install_path: Pathname(location).join(name),
19
+ install_path: Pathname(location).join(name)
20
20
  )
21
21
  end
22
22
  end
23
23
 
24
24
  def self.package_management_command
25
- "pip"
25
+ 'pip'
26
26
  end
27
27
 
28
28
  private
29
29
 
30
- def package_path
31
- unless project_path.nil?
32
- project_path.join(@requirements_path)
30
+ def possible_package_paths
31
+ if project_path.nil?
32
+ [@requirements_path]
33
33
  else
34
- @requirements_path
34
+ [project_path.join(@requirements_path)]
35
35
  end
36
36
  end
37
37
 
38
38
  def pip_output
39
- output = `#{LicenseFinder::BIN_PATH.join("license_finder_pip.py")} #{package_path}`
39
+ output = `#{LicenseFinder::BIN_PATH.join('license_finder_pip.py')} #{detected_package_path}`
40
40
  JSON(output).map do |package|
41
- package.values_at(*%w[name version dependencies location])
41
+ package.values_at('name', 'version', 'dependencies', 'location')
42
42
  end
43
43
  end
44
44
 
45
45
  def pypi_def(name, version)
46
46
  response = HTTParty.get("https://pypi.python.org/pypi/#{name}/#{version}/json")
47
47
  if response.code == 200
48
- JSON.parse(response.body).fetch("info", {})
48
+ JSON.parse(response.body).fetch('info', {})
49
49
  else
50
50
  {}
51
51
  end
@@ -1,28 +1,28 @@
1
1
  module LicenseFinder
2
2
  class PipPackage < Package
3
3
  LICENSE_FORMAT = /^License.*::\s*(.*)$/
4
- INVALID_LICENSES = ["", "UNKNOWN"].to_set
4
+ INVALID_LICENSES = ['', 'UNKNOWN'].to_set
5
5
 
6
6
  def self.license_names_from_spec(spec)
7
- license = spec["license"].to_s.strip
7
+ license = spec['license'].to_s.strip
8
8
 
9
9
  return [license] unless INVALID_LICENSES.include?(license)
10
10
 
11
11
  spec
12
- .fetch("classifiers", [])
12
+ .fetch('classifiers', [])
13
13
  .select { |c| c =~ LICENSE_FORMAT }
14
14
  .map { |c| c.gsub(LICENSE_FORMAT, '\1') }
15
15
  end
16
16
 
17
- def initialize(name, version, spec, options={})
17
+ def initialize(name, version, spec, options = {})
18
18
  super(
19
19
  name,
20
20
  version,
21
21
  options.merge(
22
- authors: spec["author"],
23
- summary: spec["summary"],
24
- description: spec["description"],
25
- homepage: spec["home_page"],
22
+ authors: spec['author'],
23
+ summary: spec['summary'],
24
+ description: spec['description'],
25
+ homepage: spec['home_page'],
26
26
  spec_licenses: self.class.license_names_from_spec(spec)
27
27
  )
28
28
  )
@@ -1,9 +1,9 @@
1
1
  module LicenseFinder
2
2
  class Rebar < PackageManager
3
- def initialize(options={})
3
+ def initialize(options = {})
4
4
  super
5
- @command = options[:rebar_command] || Rebar::package_management_command
6
- @deps_path = Pathname(options[:rebar_deps_dir] || "deps")
5
+ @command = options[:rebar_command] || Rebar.package_management_command
6
+ @deps_path = Pathname(options[:rebar_deps_dir] || 'deps')
7
7
  end
8
8
 
9
9
  def current_packages
@@ -19,24 +19,24 @@ module LicenseFinder
19
19
  end
20
20
 
21
21
  def self.package_management_command
22
- "rebar"
22
+ 'rebar'
23
23
  end
24
24
 
25
25
  private
26
26
 
27
27
  def rebar_ouput
28
28
  command = "#{@command} list-deps"
29
- output, success = Dir.chdir(project_path) { capture(command) }
30
- raise "Command '#{command}' failed to execute: #{output}" unless success
29
+ stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
30
+ raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
31
31
 
32
- output
32
+ stdout
33
33
  .each_line
34
- .reject { |line| line.start_with?("=") }
35
- .map { |line| line.split(" ") }
34
+ .reject { |line| line.start_with?('=') }
35
+ .map { |line| line.split(' ') }
36
36
  end
37
37
 
38
- def package_path
39
- project_path.join('rebar.config')
38
+ def possible_package_paths
39
+ [project_path.join('rebar.config')]
40
40
  end
41
41
  end
42
42
  end
@@ -0,0 +1,62 @@
1
+ module LicenseFinder
2
+ class Yarn < PackageManager
3
+ SHELL_COMMAND = 'yarn licenses list --no-progress --json'.freeze
4
+
5
+ def possible_package_paths
6
+ [project_path.join('yarn.lock')]
7
+ end
8
+
9
+ def current_packages
10
+ stdout, _stderr, status = Cmd.run(Yarn::SHELL_COMMAND)
11
+ return [] unless status.success?
12
+
13
+ packages = []
14
+ incompatible_packages = []
15
+
16
+ json_strings = stdout.split("\n")
17
+ json_objects = json_strings.map { |json_object| JSON.parse(json_object) }
18
+
19
+ if json_objects.last['type'] == 'table'
20
+ license_json = json_objects.pop['data']
21
+ packages = packages_from_json(license_json)
22
+ end
23
+
24
+ json_objects.each do |json_object|
25
+ match = /(?<name>[\w,\-]+)@(?<version>(\d+\.?)+)/ =~ json_object['data'].to_s
26
+ if match
27
+ package = Package.new(name, version, spec_licenses: ['unknown'])
28
+ incompatible_packages.push(package)
29
+ end
30
+ end
31
+
32
+ packages + incompatible_packages.uniq
33
+ end
34
+
35
+ def self.takes_priority_over
36
+ NPM
37
+ end
38
+
39
+ def self.package_management_command
40
+ 'yarn'
41
+ end
42
+
43
+ def self.prepare_command
44
+ 'yarn install'
45
+ end
46
+
47
+ private
48
+
49
+ def packages_from_json(json_data)
50
+ body = json_data['body']
51
+ head = json_data['head']
52
+
53
+ packages = body.map do |json_package|
54
+ Hash[head.zip(json_package)]
55
+ end
56
+
57
+ packages.map do |package_hash|
58
+ Package.new(package_hash['Name'], package_hash['Version'], spec_licenses: [package_hash['License']], homepage: package_hash['VendorUrl'])
59
+ end
60
+ end
61
+ end
62
+ end
@@ -6,13 +6,13 @@ module LicenseFinder
6
6
 
7
7
  class FromDecision < Basic
8
8
  def sources
9
- ["from decision"]
9
+ ['from decision']
10
10
  end
11
11
  end
12
12
 
13
13
  class FromSpec < Basic
14
14
  def sources
15
- ["from spec"]
15
+ ['from spec']
16
16
  end
17
17
  end
18
18
 
@@ -2,8 +2,8 @@ require 'license_finder/packages/possible_license_file'
2
2
 
3
3
  module LicenseFinder
4
4
  class LicenseFiles
5
- CANDIDATE_FILE_NAMES = %w(LICENSE License Licence COPYING README Readme ReadMe)
6
- CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*"
5
+ CANDIDATE_FILE_NAMES = %w[LICENSE License Licence COPYING README Readme ReadMe].freeze
6
+ CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*".freeze
7
7
 
8
8
  def self.find(install_path)
9
9
  new(install_path).find
@@ -24,10 +24,10 @@ module LicenseFinder
24
24
  attr_reader :install_path
25
25
 
26
26
  def paths_of_candidate_files
27
- candidate_files_and_dirs.
28
- flat_map { |path| path.directory? ? path.children : path }.
29
- reject { |path| path.directory? }.
30
- uniq
27
+ candidate_files_and_dirs
28
+ .flat_map { |path| path.directory? ? path.children : path }
29
+ .reject(&:directory?)
30
+ .uniq
31
31
  end
32
32
 
33
33
  def candidate_files_and_dirs
@@ -2,33 +2,31 @@ require 'license_finder/packages/activation'
2
2
 
3
3
  module LicenseFinder
4
4
  Licensing = Struct.new(:package, :decided_licenses, :licenses_from_spec, :license_files) do
5
-
6
5
  # Implements the algorithm for choosing the right set of licenses from
7
6
  # among the various sources of licenses we know about. In order of
8
7
  # priority, licenses come from decisions, package specs, or package files.
9
8
  def activations
10
- case
11
- when activations_from_decisions.any? then activations_from_decisions
12
- when activations_from_spec.any? then activations_from_spec
13
- when activations_from_files.any? then activations_from_files
14
- else [default_activation]
9
+ if activations_from_decisions.any? then activations_from_decisions
10
+ elsif activations_from_spec.any? then activations_from_spec
11
+ elsif activations_from_files.any? then activations_from_files
12
+ else [default_activation]
15
13
  end
16
14
  end
17
15
 
18
16
  def activations_from_decisions
19
17
  @afd ||= decided_licenses
20
- .map { |license| Activation::FromDecision.new(package, license) }
18
+ .map { |license| Activation::FromDecision.new(package, license) }
21
19
  end
22
20
 
23
21
  def activations_from_spec
24
22
  @afs ||= licenses_from_spec
25
- .map { |license| Activation::FromSpec.new(package, license) }
23
+ .map { |license| Activation::FromSpec.new(package, license) }
26
24
  end
27
25
 
28
26
  def activations_from_files
29
27
  @aff ||= license_files
30
- .group_by(&:license)
31
- .map { |license, files| Activation::FromFiles.new(package, license, files) }
28
+ .group_by(&:license)
29
+ .map { |license, files| Activation::FromFiles.new(package, license, files) }
32
30
  end
33
31
 
34
32
  def default_activation
@@ -5,11 +5,11 @@ module LicenseFinder
5
5
  end
6
6
 
7
7
  def eql?(other)
8
- name == other.name # && version.to_s == other.version.to_s # ignore version
8
+ name == other.name
9
9
  end
10
10
 
11
11
  def hash
12
- name.hash # ^ version.to_s.hash # ignore version
12
+ name.hash
13
13
  end
14
14
 
15
15
  private
@@ -17,10 +17,11 @@ module LicenseFinder
17
17
 
18
18
  def collect_project_path(all_paths)
19
19
  potential_project_path = all_paths.first
20
- if active_project?(potential_project_path)
21
- remove_nested(potential_project_path, all_paths)
22
- return potential_project_path.to_s
23
- end
20
+ is_active_project = active_project?(potential_project_path)
21
+ return unless is_active_project
22
+
23
+ remove_nested(potential_project_path, all_paths)
24
+ potential_project_path.to_s
24
25
  end
25
26
 
26
27
  private
@@ -50,7 +51,7 @@ module LicenseFinder
50
51
  end
51
52
 
52
53
  def nested_path?(path, pathname)
53
- (path.to_s).start_with?(pathname.to_s) && path.to_s != pathname.to_s
54
+ path.to_s.start_with?(pathname.to_s) && path.to_s != pathname.to_s
54
55
  end
55
56
  end
56
57
  end
@@ -10,6 +10,7 @@ module LicenseFinder
10
10
  end
11
11
 
12
12
  private
13
+
13
14
  attr_reader :dependencies, :project_name
14
15
 
15
16
  def sorted_dependencies
@@ -2,9 +2,9 @@ require 'csv'
2
2
 
3
3
  module LicenseFinder
4
4
  class CsvReport < Report
5
- COMMA_SEP = ","
6
- AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups]
7
- MISSING_DEPENDENCY_TEXT = "This package is not installed. Please install to determine licenses."
5
+ COMMA_SEP = ','.freeze
6
+ AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups].freeze
7
+ MISSING_DEPENDENCY_TEXT = 'This package is not installed. Please install to determine licenses.'.freeze
8
8
 
9
9
  def initialize(dependencies, options)
10
10
  super
@@ -56,7 +56,7 @@ module LicenseFinder
56
56
  end
57
57
 
58
58
  def format_approved(dep)
59
- dep.approved? ? "Approved" : "Not approved"
59
+ dep.approved? ? 'Approved' : 'Not approved'
60
60
  end
61
61
 
62
62
  def format_summary(dep)
@@ -2,7 +2,7 @@ module LicenseFinder
2
2
  class DiffReport < CsvReport
3
3
  AVAILABLE_COLUMNS = AVAILABLE_COLUMNS + %w[status current_version previous_version project_paths]
4
4
 
5
- def initialize(dependencies, options={})
5
+ def initialize(dependencies, options = {})
6
6
  super(dependencies, options.merge(columns: build_columns(dependencies)))
7
7
  end
8
8
 
@@ -22,7 +22,7 @@ module LicenseFinder
22
22
 
23
23
  def build_columns(dependencies)
24
24
  columns = %w[status name version licenses]
25
- columns << 'project_paths' if dependencies.all? { |delta| delta.merged_package? }
25
+ columns << 'project_paths' if dependencies.all?(&:merged_package?)
26
26
  columns
27
27
  end
28
28
  end
@@ -38,7 +38,7 @@ module LicenseFinder
38
38
  end
39
39
 
40
40
  def link_to(text, link = "##{text}")
41
- %{<a href="#{link}">#{text}</a>}
41
+ %(<a href="#{link}">#{text}</a>)
42
42
  end
43
43
 
44
44
  def license_names(dependency)
@@ -51,9 +51,7 @@ module LicenseFinder
51
51
 
52
52
  def version_groups(dependency)
53
53
  result = "v#{dependency.version}"
54
- if dependency.groups.any?
55
- result << " (#{dependency.groups.join(", ")})"
56
- end
54
+ result << " (#{dependency.groups.join(', ')})" if dependency.groups.any?
57
55
  result
58
56
  end
59
57
  end
@@ -3,11 +3,11 @@ module LicenseFinder
3
3
  private
4
4
 
5
5
  def template_name
6
- "html_report"
6
+ 'html_report'
7
7
  end
8
8
 
9
9
  def bootstrap
10
- TEMPLATE_PATH.join("bootstrap.css").read
10
+ TEMPLATE_PATH.join('bootstrap.css').read
11
11
  end
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@ module LicenseFinder
3
3
  private
4
4
 
5
5
  def template_name
6
- "markdown_report"
6
+ 'markdown_report'
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module LicenseFinder
3
3
  AVAILABLE_COLUMNS = AVAILABLE_COLUMNS + ['subproject_paths']
4
4
 
5
5
  def initialize(dependencies, options = {})
6
- options[:columns] ||= %w(name version licenses subproject_paths)
6
+ options[:columns] ||= %w[name version licenses subproject_paths]
7
7
  super(dependencies, options)
8
8
  end
9
9
 
@@ -1,14 +1,12 @@
1
1
  module LicenseFinder
2
2
  class TextReport < CsvReport
3
- COMMA_SEP = ", "
3
+ COMMA_SEP = ', '.freeze
4
4
 
5
- def initialize(dependencies, options={})
5
+ def initialize(dependencies, options = {})
6
6
  super(dependencies, options)
7
7
 
8
8
  default_columns = %w[name version licenses]
9
- if @columns.empty?
10
- @columns = default_columns
11
- end
9
+ @columns = default_columns if @columns.empty?
12
10
  end
13
11
  end
14
12
  end