[ANN] rails_best_practices 0.6.3 released

flyerhzm Posted by flyerhzm on January 01, 2011

Comments

I just released rails_best_practices 0.6.3, it provides a html format for more readable output. By default, the colorful output of rails_best_practices is printed on terminal. Now you can type

rails_best_practices -f html .

or

rails_best_practices --format html .

to generate a html output. The html output is like this

rails_best_practices html output

Hope you like the html format.

[ANN] rails_best_practices 0.6.2 released

flyerhzm Posted by flyerhzm on December 31, 2010

Comments

This is also a bug fixed version.

As issue 29 reported, the following error will be raised when checking law of demeter.

rails_best_practices-0.6.1/lib/rails_best_practices/checks/check.rb:199:in `+': can't convert nil into String

thanks @roelbondoc helping me solved this problem. It is caused by Sexp#to_s method, this method only handles nodes whose node type are lvar, ivar, lit, const, array or hash in 0.6.1 gem, such as

s(:ivar, :@user)  =>  @user
s(:array, s(:ivar, :@user1), s(:ivar, :@user2))  =>  [@user1, @user2]

but if the to_s method called on node whose node type is colon2, it will return nil, which causes the issue. So roelbondoc adds the following codes to handle the colon2

case node_type
...
when :colon2
  "#{self[1]}::#{self[2]}"
end

Then the issue was solved, cool. And to avoid the potential bugs, I added the else block with empty string

case node_type
...
when :colon2
  "#{self[1]}::#{self[2]}"
else
  ""
end

I think the issue 29 will never occur.

[ANN] rails_best_practices 0.6.1 released

flyerhzm Posted by flyerhzm on December 24, 2010

Comments

This is a bug fixed version.

As issue reported here, the runtime error will be raised if you use rails_best_practices 0.6.0 to analyze rails2 projects or rails3 projects without app/mailers directory.

The issue is caused by the following codes

files = []
['models', 'mailers'].each do |name|
  files += expand_dirs_to_files(File.join(@path, 'app', name))
end
files

it checks all the files under app/models and app/mailers directory, but if there is no mailers directory, there is a nil element in files array. After that I will read all the files in files array, and the nil element raise the error.

The solution is compact the files array to remove nil element.

files.compact

If you meet the runtime error, please upgrade to rails_best_practices 0.6.1.

[Announcement] rails_best_practices 0.6.0 released

flyerhzm Posted by flyerhzm on December 24, 2010

Comments

I have released rails_best_practices 0.6.0.

In this version, I did a lot of refactorings, the check process is partitioned into two parts, one is prepare process (analyze models, associations and so on.) and the other is review process (check all files to find the violations of best practices). Absolutely I added more rspec tests before refactoring which made rails_best_practices robuster.

I also added a lot of comments to make the source codes much easier to read and understand. After that I built a rdoc website by yard, but I still recommend you to read the source codes, as there are some comments on metaprogramming codes that are not shown on rdoc.

Last but not least, I created a google group for rails_best_practices, you can post any suggestions, questions and discussions there.

Welcome to rails-bestpractices.com

flyerhzm Posted by flyerhzm on December 22, 2010

Comments

Welcome to the new rails-bestpractices.com blog where we'll be posting about rails_best_practices gem and rails-bestpractices.com website.