On Dec 31, 2008, at 08:20 , Daniel Berger wrote:
Just for kicks I ran Ryan's flay against the rubygems files. Here
were the results for anyone interested. I haven't investigated
further to see how many of these warrant refactoring.
Just to tease you, here is what the next version of flay can do for
you (I took out #2 to reduce noise):
1) Similar code found in :defn (mass = 156)
A: lib/rubygems/config_file.rb:251
B: lib/rubygems/package/tar_header.rb:178
C: lib/rubygems/source_info_cache_entry.rb:49
def ==(other)
A: (self.class.===(other) and ((@backtrace == other.backtrace) and
((@benchmark == other.benchmark) and ((@bulk_threshold ==
other.bulk_threshold) and ((@verbose == other.verbose) and
((@update_sources == other.update_sources) and (@hash ==
other.hash)))))))
B: (self.class.===(other) and ((@checksum == other.checksum) and
((@devmajor == other.devmajor) and ((@devminor == other.devminor) and
((@gid == other.gid) and ((@gname == other.gname) and ((@linkname ==
other.linkname) and ((@magic == other.magic) and ((@mode ==
other.mode) and ((@mtime == other.mtime) and ((@name == other.name)
and ((@prefix == other.prefix) and ((@size == other.size) and
((@typeflag == other.typeflag) and ((@uid == other.uid) and ((@uname
== other.uname) and (@version == other.version)))))))))))))))))
C: (self.class.===(other) and ((@size == other.size) and
(@source_index == other.source_index)))
end
3) IDENTICAL code found in :block (mass*2 = 100)
A: lib/rubygems/indexer.rb:234
B: lib/rubygems/indexer.rb:250
platform = spec.original_platform
platform = Gem::Platform::RUBY if (platform.nil? or platform.empty?)
[spec.name, spec.version, platform]
4) Similar code found in :if (mass = 98)
A: lib/rubygems/security.rb:696
B: lib/rubygems/security.rb:708
A: if opt[:save_key] then
B: if opt[:save_cert] then
A: path[:key] = (opt[:save_key_path] or (opt[:output_fmt] %
"private_key"))
B: path[:cert] = (opt[:save_cert_path] or (opt[:output_fmt] %
"public_cert"))
A: File.open(path[:key], "wb") do |file|
B: File.open(path[:cert], "wb") do |file|
A: file.chmod(opt[:perms][:signing_key])
B: file.chmod(opt[:perms][:signing_cert])
A: file.write(key.to_pem)
B: file.write(cert.to_pem)
end
end
_______________________________________________
Rubygems-developers mailing list
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers