lib/licensed/commands/status.rb in licensed-3.1.0 vs lib/licensed/commands/status.rb in licensed-3.2.0

- old
+ new

@@ -13,26 +13,21 @@ Licensed::Reporters::StatusReporter.new end protected - # Run the command for all enumerated dependencies found in a dependency source, - # recording results in a report. - # Enumerating dependencies in the source is skipped if a :sources option - # is provided and the evaluated `source.class.type` is not in the :sources values + # Run the comand and set an error message to review the documentation + # when any errors have been reported # - # app - The application configuration for the source - # source - A dependency source enumerator + # report - A Licensed::Report object for this command # - # Returns whether the command succeeded for the dependency source enumerator - def run_source(app, source) - super do |report| - next if Array(options[:sources]).empty? - next if options[:sources].include?(source.class.type) + # Returns whether the command succeeded based on the call to super + def run_command(report) + super do |result| + next if result - report.warnings << "skipped source" - :skip + report.errors << "Licensed found errors during source enumeration. Please see https://github.com/github/licensed/tree/master/docs/commands/status.md#status-errors-and-resolutions for possible resolutions." end end # Verifies that a cached record exists, is up to date and # has license data that complies with the licensed configuration. @@ -45,24 +40,27 @@ # Returns whether the dependency has a cached record that is compliant # with the licensed configuration. def evaluate_dependency(app, source, dependency, report) filename = app.cache_path.join(source.class.type, "#{dependency.name}.#{DependencyRecord::EXTENSION}") report["filename"] = filename + report["version"] = dependency.version cached_record = cached_record(filename) if cached_record.nil? + report["license"] = nil report.errors << "cached dependency record not found" else + report["license"] = cached_record["license"] report.errors << "cached dependency record out of date" if cached_record["version"] != dependency.version report.errors << "missing license text" if cached_record.licenses.empty? if cached_record["review_changed_license"] report.errors << "license text has changed and needs re-review. if the new text is ok, remove the `review_changed_license` flag from the cached record" elsif license_needs_review?(app, cached_record) report.errors << "license needs review: #{cached_record["license"]}" end end - report.errors.empty? + report["allowed"] = report.errors.empty? end # Returns true if a cached record needs further review based on the # record's license(s) and the app's configuration def license_needs_review?(app, cached_record)