flyerhzm / rails_best_practices

a code metric tool for rails projects
http://rails-bestpractices.com
MIT License
4.16k stars 276 forks source link

Cannot output to pipe when -f option is specified #354

Open naokikimura opened 4 years ago

naokikimura commented 4 years ago

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

% 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?