rails_best_practices icon indicating copy to clipboard operation
rails_best_practices copied to clipboard

Cannot output to pipe when -f option is specified

Open naokikimura opened this issue 4 years ago • 0 comments

When the -f option is specified in CLI, there is no way to write the analysis result to the pipe.

  • When the -f option is specified and --output-file option is not specified, the analysis result is output to a file with the default file name.
  • An error will occur if you connect to a pipe by giving /dev/null to the --output-file option with the -f option specified.
% rails_best_practices --silent -f xml --output-file /dev/stdout | cat       
Traceback (most recent call last):
        9: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/bin/rails_best_practices:23:in `<main>'
        8: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/bin/rails_best_practices:23:in `load'
        7: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/bin/rails_best_practices:7:in `<top (required)>'
        6: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        5: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        4: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/lib/rails_best_practices/command.rb:15:in `<top (required)>'
        3: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/lib/rails_best_practices/analyzer.rb:75:in `output'
        2: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/lib/rails_best_practices/analyzer.rb:278:in `output_xml_errors'
        1: from /Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/lib/rails_best_practices/analyzer.rb:278:in `open'
/Users/kimuranaoki/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rails_best_practices-1.20.0/lib/rails_best_practices/analyzer.rb:278:in `initialize': Permission denied @ rb_sysopen - /dev/stdout (Errno::EACCES)

I want to output the analysis result as XML and transform it with XSLT. I don't want to output an intermediate XML file.

Why open output file in w+ mode?

naokikimura avatar Mar 02 '20 14:03 naokikimura