Skip to content

Commit

Permalink
Display detected technologies when running the tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkononov authored Mar 5, 2024
1 parent 3dbe6f2 commit 1e409a2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
15 changes: 12 additions & 3 deletions lib/package/audit/services/command_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

module Package
module Audit
class CommandParser
class CommandParser # rubocop:disable Metrics/ClassLength
def initialize(dir, options, report)
@dir = dir
@options = options
Expand All @@ -22,7 +22,7 @@ def initialize(dir, options, report)
@groups = @options[Enum::Option::GROUP]
@technologies = parse_technologies!
validate_format!
@spinner = Util::Spinner.new('Evaluating packages and their dependencies...')
@spinner = Util::Spinner.new("Evaluating packages and their dependencies for #{human_readable_technologies}...")
end

def run
Expand Down Expand Up @@ -123,7 +123,16 @@ def validate_format!
def parse_technologies!
technology_validator = Technology::Validator.new(@dir)
@options[Enum::Option::TECHNOLOGY]&.each { |technology| technology_validator.validate! technology }
@options[Enum::Option::TECHNOLOGY] || Technology::Detector.new(@dir).detect
(@options[Enum::Option::TECHNOLOGY] || Technology::Detector.new(@dir).detect).sort
end

def human_readable_technologies
array = @technologies.map(&:capitalize)
return '' if array.nil?
return array.join if array.size <= 1
return array.join(' and ') if array.size == 2

"#{array[0..-2].join(', ')}, and #{array.last}"
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions sig/package/audit/services/command_parser.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Package

private

def human_readable_technologies: -> String

def learn_more_command: (String) -> String?

def parse_config_file!: -> Hash[String, untyped]?
Expand Down
12 changes: 12 additions & 0 deletions steep_expectations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@
severity: WARNING
message: 'Cannot find the declaration of constant: `Bundler`'
code: Ruby::UnknownConstant
- file: lib/package/audit/services/command_parser.rb
diagnostics:
- range:
start:
line: 135
character: 24
end:
line: 135
character: 28
severity: ERROR
message: Type `(::Array[::String] | nil)` does not have method `join`
code: Ruby::NoMethod
- file: lib/package/audit/services/package_printer.rb
diagnostics:
- range:
Expand Down
2 changes: 1 addition & 1 deletion test/package/test_audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_that_there_is_a_report_of_gems
output = `bundle exec package-audit test/files/gemfile/report`

assert_match 'Found a total of 3 ruby packages.', output
assert_match '1 vulnerable (8 vulnerabilities), 2 outdated, 1 deprecated.', output
assert_match '1 vulnerable (11 vulnerabilities), 2 outdated, 1 deprecated.', output
end

def test_that_there_is_a_message_about_outdated_gems
Expand Down

0 comments on commit 1e409a2

Please sign in to comment.