lib/travis/cli/lint.rb in travis-1.11.1 vs lib/travis/cli/lint.rb in travis-1.12.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'travis/cli' require 'yaml' module Travis module CLI @@ -7,19 +9,19 @@ description 'display warnings for a .travis.yml' on '-q', '--[no-]quiet', 'does not print anything' on '-x', '--[no-]exit-code', 'sets the exit code to 1 if there are warning' def run(file = nil) - file ||= '.travis.yml' if $stdin.tty? or $stdin.eof? + file ||= '.travis.yml' if $stdin.tty? || $stdin.eof? - if file and file != '-' + if file && (file != '-') debug "reading #{file}" error "file does not exist: #{color(file, :bold)}" unless File.exist? file error "cannot read #{color(file, :bold)}" unless File.readable? file content = File.read(file) else - debug "reading stdin" + debug 'reading stdin' file = 'STDIN' content = $stdin.read end begin @@ -30,27 +32,27 @@ lint = session.lint(content) unless quiet? if lint.ok? - say "valid", color("Hooray, #{file} looks %s :)", :success) + say 'valid', color("Hooray, #{file} looks %s :)", :success) else say "Warnings for #{color(file, :info)}:" lint.warnings.each do |warning| - say color('[x]', [:red, :bold]) + " " + say "#{color('[x]', %i[red bold])} " if warning.key.any? say [ color('in ', :info), - color(warning.key.join('.'), [:info, :bold, :underline]), + color(warning.key.join('.'), %i[info bold underline]), color(' section:', :info), ' ' ].join end - say warning.message.gsub(/"(.*?)"/) { color($1, [:info, :important]) } + say warning.message.gsub(/"(.*?)"/) { color(::Regexp.last_match(1), %i[info important]) } end end end - exit 1 if lint.warnings? and exit_code? + exit 1 if lint.warnings? && exit_code? end end end end