def collect_warnings(files, scanner)
      full_list = files.map do |file|
        data = file == '(stdin)' ? STDIN.read : File.read(file)
        if scanner.settings[:fix]
          scanner.settings[:output_file] = scanner.settings[:stdin] ? STDOUT : File.open(file, 'w')
        end
        results = scanner.scan(data, file)
        if scanner.settings[:fix] && !scanner.settings[:stdin]
          scanner.settings[:output_file].close
        end
        results
      end
      full_list.flatten
    end
def collect_warnings(files, scanner)
      full_list = files.map do |file|
        data = file == '(stdin)' ? STDIN.read : File.read(file)
        if scanner.settings[:fix]
          scanner.settings[:output_file] = scanner.settings[:stdin] ? STDOUT : File.open(file, 'w')
        end
        results = scanner.scan(data, file)
        if scanner.settings[:fix] && !scanner.settings[:stdin]
          scanner.settings[:output_file].close
        end
        results
      end
      full_list.flatten
    end
Collects warnings from all the provided files by running them through
 the scanner.

 @param [Array<String>] files the files to scan. If (stdin) is in the
   array, then data will be read from STDIN until EOF is reached.
 @param [Scanner] scanner the scanner that will look for warnings
   in the source text.
 @return [Array<Warning>] a set of warnings, ordered by file.