source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
Ruby
mit
4,169
main
1,033
# frozen_string_literal: true module RailsBestPractices module Reviews # Review view and helper files to make sure not use time_ago_in_words or distance_of_time_in_words_to_now. # # See the best practice details here https://rails-bestpractices.com/posts/2012/02/10/not-use-time_ago_in_words/ # # ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/needless_deep_nesting_review.rb
Ruby
mit
4,169
main
3,302
# frozen_string_literal: true module RailsBestPractices module Reviews # Review config/routes.rb file to make sure not to use too deep nesting routes. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/22/needless-deep-nesting/ # # Implementation: # # Rev...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/hash_syntax_review.rb
Ruby
mit
4,169
main
1,418
# frozen_string_literal: true module RailsBestPractices module Reviews # Check ruby 1.8 style hash and suggest to change hash syntax to 1.9. # # Review process: # check hash nodes in all files, # if the sexp type of hash key nodes is not :@lable, # then the hash is ruby 1.8 style. c...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb
Ruby
mit
4,169
main
4,645
# frozen_string_literal: true module RailsBestPractices module Reviews # Find out unused methods in controllers. # # Implementation: # # Review process: # remember all method calls in controllers, # if they are not defined in routes, # and they are not called in controllers, ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_query_attribute_review.rb
Ruby
mit
4,169
main
5,206
# frozen_string_literal: true module RailsBestPractices module Reviews # Make sure to use query attribute instead of nil?, blank? and present?. # # See the best practice details here https://rails-bestpractices.com/posts/2010/10/03/use-query-attribute/ # # Implementation: # # Review proce...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
Ruby
mit
4,169
main
1,065
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a partail view file to make sure there is no instance variable. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/replace-instance-variable-with-local-variable/ # # Implementation...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb
Ruby
mit
4,169
main
6,823
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a route file to make sure all auto-generated routes have corresponding actions in controller. # # See the best practice details here https://rails-bestpractices.com/posts/2011/08/19/restrict-auto-generated-routes/ # #...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb
Ruby
mit
4,169
main
2,079
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a migration file to make sure to use say or say_with_time for customized data changes # to produce a more readable output. # # See the best practice detials here https://rails-bestpractices.com/posts/2010/08/19/use-say-an...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_before_filter_review.rb
Ruby
mit
4,169
main
2,517
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller file to make sure to use before_filter to remove duplicated first code # line_number in different action. # # See the best practice detailed here https://rails-bestpractices.com/posts/2010/07/24/use-before_fi...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
Ruby
mit
4,169
main
1,604
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a view file to make sure using simplified syntax for render. # # See the best practice details here https://rails-bestpractices.com/posts/2010/12/04/simplify-render-in-views/ # # Implementation: # # Review pro...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/not_use_default_route_review.rb
Ruby
mit
4,169
main
1,171
# frozen_string_literal: true module RailsBestPractices module Reviews # Review config/routes file to make sure not use default route that rails generated. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/22/not-use-default-route-if-you-use-restful-design/ # # ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb
Ruby
mit
4,169
main
1,141
# frozen_string_literal: true module RailsBestPractices module Reviews # Prepare Gemfile and review Capfile file to make sure using turbo-sprocket-rails3 # # See the best practice details here https://rails-bestpractices.com/posts/2012/11/23/speed-up-assets-precompile-with-turbo-sprockets-rails3/ # ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
Ruby
mit
4,169
main
794
# frozen_string_literal: true module RailsBestPractices module Reviews # Review model files to make sure not use default_scope # # See the best practice details here https://rails-bestpractices.com/posts/2013/06/15/default_scope-is-evil/ # # Implementation: # # Review process: # che...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb
Ruby
mit
4,169
main
2,752
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller file to make sure that complex model creation should not exist in # controller, should be replaced with factory method. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/21/...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/move_code_into_model_review.rb
Ruby
mit
4,169
main
1,772
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a view file to make sure there is no complex logic call for model. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/move-code-into-model/ # # Implementation: # # Review p...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/check_destroy_return_value_review.rb
Ruby
mit
4,169
main
2,458
# frozen_string_literal: true module RailsBestPractices module Reviews # Review all code to make sure we either check the return value of "destroy" # or use "destroy!" # # Review process: # Track which nodes are used by 'if', 'unless', '&&' nodes etc. as we pass them by. # Check all "save...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb
Ruby
mit
4,169
main
1,318
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller file to make sure using simplified syntax for render. # # See the best practice details here https://rails-bestpractices.com/posts/2010/12/12/simplify-render-in-controllers/ # # Implementation: # ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb
Ruby
mit
4,169
main
1,109
# frozen_string_literal: true module RailsBestPractices module Reviews # Review config/deploy.rb file to make sure using the bundler's capistrano recipe. # # See the best practice details here https://rails-bestpractices.com/posts/2010/09/02/dry-bundler-in-capistrano/ # # Implementation: # ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/isolate_seed_data_review.rb
Ruby
mit
4,169
main
2,534
# frozen_string_literal: true module RailsBestPractices module Reviews # Make sure not to insert data in migration, move them to seed file. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/isolating-seed-data/ # # Implementation: # # Review process: ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb
Ruby
mit
4,169
main
2,222
# frozen_string_literal: true module RailsBestPractices module Reviews # Make sure to use multipart/alternative as content_type of email. # # See the best practice details here https://rails-bestpractices.com/posts/2010/08/05/use-multipart-alternative-as-content_type-of-email/ # # Implementation:...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/check_save_return_value_review.rb
Ruby
mit
4,169
main
3,323
# frozen_string_literal: true module RailsBestPractices module Reviews # Review all code to make sure we either check the return value of "save", "update_attributes" # and "create" or use "save!", "update_attributes!", or "create!", respectively. # # See the best practice details here https://rails-b...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/always_add_db_index_review.rb
Ruby
mit
4,169
main
7,885
# frozen_string_literal: true module RailsBestPractices module Reviews # Review db/schema.rb file to make sure every reference key has a database index. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/always-add-db-index/ # # Implementation: # # Rev...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb
Ruby
mit
4,169
main
3,816
# frozen_string_literal: true require_rel 'review' module RailsBestPractices module Reviews # Make sure to add a model virual attribute to simplify model creation. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/21/add-model-virtual-attribute/ # # Implementat...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/protect_mass_assignment_review.rb
Ruby
mit
4,169
main
3,537
# frozen_string_literal: true module RailsBestPractices module Reviews # Review model files to make sure to use attr_accessible, attr_protected or strong_parameters to protect mass assignment. # # See the best practices details here https://rails-bestpractices.com/posts/2012/03/06/protect-mass-assignment...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core_ext/erubis.rb
Ruby
mit
4,169
main
546
# frozen_string_literal: true require 'erubis' module Erubis class OnlyRuby < Eruby def add_preamble(src); end def add_text(src, text) src << text.gsub(/[^\s;]/, '') end def add_stmt(src, code) src << code src << ';' end def add_expr_literal(src, code) src << code ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/routes.rb
Ruby
mit
4,169
main
1,541
# frozen_string_literal: true module RailsBestPractices module Core class Routes < Array # add a route. # # @param [Array] namesapces # @param [String] controller name # @param [String] action name def add_route(namespaces, controller_name, action_name) if namespaces.p...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/checks_loader.rb
Ruby
mit
4,169
main
1,438
# frozen_string_literal: true module RailsBestPractices module Core class ChecksLoader def initialize(config) @config = config end # load all lexical checks. def load_lexicals load_checks_from_config { |check_name| RailsBestPractices::Lexicals.const_get(check_name) } ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/check.rb
Ruby
mit
4,169
main
14,178
# frozen_string_literal: true module RailsBestPractices module Core # A Check class that takes charge of checking the sexp. class Check < CodeAnalyzer::Checker ALL_FILES = /.*/.freeze CONTROLLER_FILES = %r{app/(controllers|cells)/.*\.rb$}.freeze MIGRATION_FILES = %r{db/migrate/.*\.rb$}.fre...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/gems.rb
Ruby
mit
4,169
main
556
# frozen_string_literal: true module RailsBestPractices module Core class Gems < Array def has_gem?(gem_name) find { |gem| gem.name == gem_name } end def gem_version(gem_name) find { |gem| gem.name == gem_name }.try(:version) end end # Gem info includes gem name ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/methods.rb
Ruby
mit
4,169
main
5,845
# frozen_string_literal: true module RailsBestPractices module Core # Method container. class Methods def initialize @methods = {} @possible_methods = {} end # Add a method. # # @param [String] class name # @param [String] method name # @param [Hash]...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/modules.rb
Ruby
mit
4,169
main
920
# frozen_string_literal: true module RailsBestPractices module Core # Module container class Modules < Array # add module descendant. # # @param [String] module name # @param [String] descendant name def add_module_descendant(module_name, descendant) mod = find { |mod| m...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/error.rb
Ruby
mit
4,169
main
884
# frozen_string_literal: true module RailsBestPractices module Core # Error is the violation to rails best practice. # # it indicates the filenname, line number and error message for the violation. class Error < CodeAnalyzer::Warning attr_reader :type, :url attr_accessor :git_commit, :git...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/runner.rb
Ruby
mit
4,169
main
7,094
# frozen_string_literal: true require 'yaml' require 'active_support/core_ext/object/blank' begin require 'active_support/core_ext/object/try' rescue LoadError require 'active_support/core_ext/try' end require 'active_support/inflector' module RailsBestPractices module Core # Runner is the main class, it ca...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/model_associations.rb
Ruby
mit
4,169
main
2,231
# frozen_string_literal: true module RailsBestPractices module Core # Model associations container. class ModelAssociations def initialize @associations = {} end # # @param [String] model name # @param [String] association name # @param [String] association meta, ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/klasses.rb
Ruby
mit
4,169
main
837
# frozen_string_literal: true module RailsBestPractices module Core # Klass container. class Klasses < Array # If include the class. # # @param [String] class name # @return [Boolean] include or not def include?(class_name) find { |klass| klass.to_s == class_name } ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/core/model_attributes.rb
Ruby
mit
4,169
main
1,179
# frozen_string_literal: true module RailsBestPractices module Core # Model attributes container. class ModelAttributes def initialize @attributes = {} end # Add a model attribute. # # @param [String] model name # @param [String] attribute name # @param [Str...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/mailer_prepare.rb
Ruby
mit
4,169
main
631
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember the mailer names. class MailerPrepare < Core::Check include Core::Check::Classable interesting_nodes :class interesting_files MAILER_FILES, MODEL_FILES def initialize @mailers = Prepares.mail...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/initializer_prepare.rb
Ruby
mit
4,169
main
980
# frozen_string_literal: true module RailsBestPractices module Prepares # Check all initializers class InitializerPrepare < Core::Check interesting_nodes :method_add_arg, :class interesting_files INITIALIZER_FILES def initialize @configs = Prepares.configs end # check...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/config_prepare.rb
Ruby
mit
4,169
main
554
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember all configs class ConfigPrepare < Core::Check interesting_nodes :assign interesting_files CONFIG_FILES def initialize @configs = Prepares.configs end # check assignments to config ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/schema_prepare.rb
Ruby
mit
4,169
main
978
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember the model attributes. class SchemaPrepare < Core::Check interesting_nodes :command, :command_call interesting_files SCHEMA_FILE # all attribute types ATTRIBUTE_TYPES = %w[integer float boolean string t...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/route_prepare.rb
Ruby
mit
4,169
main
10,916
# frozen_string_literal: true module RailsBestPractices module Prepares # Remembber routes. class RoutePrepare < Core::Check interesting_nodes :command, :command_call, :method_add_block, :do_block, :brace_block interesting_files ROUTE_FILES RESOURCES_ACTIONS = %w[index show new create edit...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/helper_prepare.rb
Ruby
mit
4,169
main
1,382
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember helper methods. class HelperPrepare < Core::Check include Core::Check::Moduleable include Core::Check::Accessable interesting_nodes :def, :command interesting_files HELPER_FILES, CONTROLLER_FILES ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/controller_prepare.rb
Ruby
mit
4,169
main
4,008
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember controllers and controller methods class ControllerPrepare < Core::Check include Core::Check::Classable include Core::Check::InheritedResourcesable include Core::Check::Accessable interesting_nodes :c...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/gemfile_prepare.rb
Ruby
mit
4,169
main
503
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember all gems in Gemfile class GemfilePrepare < Core::Check interesting_files GEMFILE_LOCK def initialize @gems = Prepares.gems end def check(_filename, content) content.split("\n").each do...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares/model_prepare.rb
Ruby
mit
4,169
main
6,645
# frozen_string_literal: true module RailsBestPractices module Prepares # Remember models and model associations. class ModelPrepare < Core::Check include Core::Check::Classable include Core::Check::Accessable interesting_nodes :class, :def, :defs, :command, :alias interesting_files...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/lexicals/long_line_check.rb
Ruby
mit
4,169
main
1,023
# frozen_string_literal: true module RailsBestPractices module Lexicals # Keep lines fewer than 80 characters. class LongLineCheck < Core::Check interesting_files ALL_FILES def initialize(options = {}) super(options) @max_line_length = options['max_line_length'] || 80 end ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/lexicals/remove_tab_check.rb
Ruby
mit
4,169
main
752
# frozen_string_literal: true module RailsBestPractices module Lexicals # Make sure there are no tabs in files. # # See the best practice details here https://rails-bestpractices.com/posts/2011/07/04/remove-tab/ class RemoveTabCheck < Core::Check interesting_files ALL_FILES url 'https://r...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
Ruby
mit
4,169
main
827
# frozen_string_literal: true module RailsBestPractices module Lexicals # Make sure there are no trailing whitespace in codes. # # See the best practice details here https://rails-bestpractices.com/posts/2010/12/02/remove-trailing-whitespace/ class RemoveTrailingWhitespaceCheck < Core::Check in...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/spec_helper.rb
Ruby
mit
4,169
main
402
# frozen_string_literal: true $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rspec' require 'rails_best_practices' require 'coveralls' Coveralls.wear! RSpec.configure do |config| config.after do RailsBestPractices::Prepares.clear end c...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/analyzer_spec.rb
Ruby
mit
4,169
main
8,190
# frozen_string_literal: true require 'spec_helper' require 'tmpdir' module RailsBestPractices describe Analyzer do subject { described_class.new('.') } describe '::new' do it 'expands a relative path to an absolute' do expect(subject.path).to eq File.expand_path('.') end end d...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/inline_disables/inline_disable_spec.rb
Ruby
mit
4,169
main
1,903
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module InlineDisables describe InlineDisable do let(:runner) { Core::Runner.new(reviews: Reviews::MoveModelLogicIntoModelReview.new) } it 'moves model logic into model' do content = <<-EOF class PostsContr...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core_ext/erubis_spec.rb
Ruby
mit
4,169
main
677
# frozen_string_literal: true require 'spec_helper' describe Erubis::OnlyRuby do subject do content = <<-EOF <h1>Title</h1> <% if current_user %> <%= link_to 'account', edit_user_path(current_user) %> <%= "Hello \#{current_user.email}" %> <% else %> Not logged in <% end %> ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/gems_spec.rb
Ruby
mit
4,169
main
653
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Gems do it { is_expected.to be_a_kind_of Array } let(:gems) { described_class.new } before do gems << Gem.new('rails', '4.0.0') gems << Gem.new('mysql2', '0.2.0') end describe '#has_gem?' d...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/error_spec.rb
Ruby
mit
4,169
main
1,010
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Error do it 'returns error with filename, line number and message' do expect( described_class.new( filename: 'app/models/user.rb', line_number: '100', message: 'not good', type: 'BogusReview' ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/methods_spec.rb
Ruby
mit
4,169
main
2,212
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Methods do let(:methods) { described_class.new } before do methods.add_method('Post', 'create') methods.add_method('Post', 'destroy') methods.add_method('Post', 'save_or_update', {}, 'protected') ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/check_spec.rb
Ruby
mit
4,169
main
354
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Check do let(:check) { described_class.new } context 'debug' do it 'is debug mode' do described_class.debug expect(described_class).to be_debug described_class.class_eval { @debug = fa...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/except_methods_spec.rb
Ruby
mit
4,169
main
1,709
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Check::Exceptable do let(:method) { Method.new 'BlogPost', 'approve', 'public', {} } context 'wildcard class and method' do let(:except_method) { '*#*' } it 'matches' do expect(described_class....
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/routes_spec.rb
Ruby
mit
4,169
main
903
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Routes do let(:routes) { described_class.new } it 'adds route' do routes.add_route(%w[admin test], 'posts', 'new') expect(routes.map(&:to_s)).to eq(['Admin::Test::PostsController#new']) end con...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/runner_spec.rb
Ruby
mit
4,169
main
2,340
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Runner do describe '#parse_html_template (haml)' do # Load Haml here so the top-level `Haml` constants used by these examples are defined # when the example group is set up and can be safely referenced/stubb...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/modules_spec.rb
Ruby
mit
4,169
main
866
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Modules do it { is_expected.to be_a_kind_of Array } context 'Modules' do before do @mod = Mod.new('PostsHelper', []) end subject { described_class.new.tap { |modules| modules << @mod } } ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/klasses_spec.rb
Ruby
mit
4,169
main
1,150
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe Klasses do it { is_expected.to be_a_kind_of Array } context 'Klass' do describe '#class_name' do it 'gets class name without module' do klass = Klass.new('BlogPost', 'Post', []) ex...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/model_associations_spec.rb
Ruby
mit
4,169
main
1,102
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe ModelAssociations do let(:model_associations) { described_class.new } before do model_associations.add_association('Project', 'project_manager', 'belongs_to') model_associations.add_association('Project...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/model_attributes_spec.rb
Ruby
mit
4,169
main
890
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe ModelAttributes do let(:model_attributes) { described_class.new } before do model_attributes.add_attribute('Post', 'title', :string) model_attributes.add_attribute('Post', 'user_id', :integer) end ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/core/checks_loader_spec.rb
Ruby
mit
4,169
main
754
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices::Core describe ChecksLoader do let(:checks_loader) { described_class.new(RailsBestPractices::Analyzer::DEFAULT_CONFIG) } describe 'load_lexicals' do it 'loads lexical checks from the default configuration' do lexica...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb
Ruby
mit
4,169
main
2,313
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe NotUseTimeAgoInWordsReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } describe 'time_ago_in_words' do it 'does not use in views' do content = <<-EOF ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb
Ruby
mit
4,169
main
4,519
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseSayWithTimeInMigrationsReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'uses say with time in migrations' do content = <<-EOF def self.up U...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb
Ruby
mit
4,169
main
1,713
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe MoveCodeIntoHelperReview do let(:runner) { Core::Runner.new(reviews: described_class.new('array_count' => 2)) } it 'moves code into helper' do content = <<-EOF <%= select_tag :state...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb
Ruby
mit
4,169
main
10,107
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe RestrictAutoGeneratedRoutesReview do let(:runner) { Core::Runner.new(prepares: Prepares::ControllerPrepare.new, reviews: described_class.new) } describe 'resources' do before do c...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb
Ruby
mit
4,169
main
1,455
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe RemoveEmptyHelpersReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'removes empty helpers' do content = <<-EOF module PostsHelper end EOF...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_observer_review_spec.rb
Ruby
mit
4,169
main
2,389
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseObserverReview do let(:runner) { Core::Runner.new(prepares: Prepares::MailerPrepare.new, reviews: described_class.new) } before do content = <<-EOF class ProjectMailer < ActionMa...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_scope_access_review_spec.rb
Ruby
mit
4,169
main
7,897
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseScopeAccessReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } context 'if' do it 'uses scope access' do content = <<-EOF class PostsController ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
Ruby
mit
4,169
main
1,880
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe MoveCodeIntoControllerReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'moves code into controller for method call' do content = <<-EOF <% Post.find(:all...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb
Ruby
mit
4,169
main
5,884
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe LawOfDemeterReview do let(:runner) do Core::Runner.new( prepares: [Prepares::ModelPrepare.new, Prepares::SchemaPrepare.new], reviews: described_class.new ) end descr...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb
Ruby
mit
4,169
main
4,385
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe MoveCodeIntoModelReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'moves code into model' do content = <<-EOF <% if current_user && @post.user && (curren...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb
Ruby
mit
4,169
main
3,180
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe NeedlessDeepNestingReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'needlesses deep nesting' do content = <<-EOF resources :posts do resources...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
Ruby
mit
4,169
main
2,026
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe ReplaceInstanceVariableWithLocalVariableReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'replaces instance variable with local varialbe' do content = <<-EOF ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb
Ruby
mit
4,169
main
1,751
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseParenthesesInMethodDefReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'finds missing parentheses' do content = <<-EOF class PostsController < Applica...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb
Ruby
mit
4,169
main
4,487
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe CheckDestroyReturnValueReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } describe 'check_destroy_return_value' do it 'warns you if you fail to check the destroy retu...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb
Ruby
mit
4,169
main
1,694
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe DefaultScopeIsEvilReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'detects default_scope with -> syntax' do content = <<-EOF class User < ActiveRecord::...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb
Ruby
mit
4,169
main
4,341
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe AddModelVirtualAttributeReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'adds model virtual attribute' do content = <<-EOF class UsersController < Appli...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_before_filter_review_spec.rb
Ruby
mit
4,169
main
3,900
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseBeforeFilterReview do let(:runner) { Core::Runner.new(reviews: described_class.new(customize_count: 2)) } it 'uses before_filter' do content = <<-EOF class PostsController < Appl...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb
Ruby
mit
4,169
main
2,134
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe DryBundlerInCapistranoReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'dries bundler in capistrno' do content = <<-EOF namespace :bundler do t...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb
Ruby
mit
4,169
main
3,449
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe NotRescueExceptionReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } describe 'not_rescue_exception' do it 'does not rescue exception in method rescue with named var'...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb
Ruby
mit
4,169
main
6,297
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe ProtectMassAssignmentReview do let(:runner) do Core::Runner.new( prepares: [Prepares::GemfilePrepare.new, Prepares::ConfigPrepare.new, Prepares::InitializerPrepare.new], review...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb
Ruby
mit
4,169
main
8,185
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseQueryAttributeReview do let(:runner) do Core::Runner.new( prepares: [Prepares::ModelPrepare.new, Prepares::SchemaPrepare.new], reviews: described_class.new ) end ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb
Ruby
mit
4,169
main
2,757
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe MoveModelLogicIntoModelReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'moves model logic into model' do content = <<-EOF class PostsController < Applic...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb
Ruby
mit
4,169
main
8,342
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe CheckSaveReturnValueReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } describe 'check_save_return_value' do it 'warns you if you fail to check save return value' do ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb
Ruby
mit
4,169
main
3,672
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe SimplifyRenderInViewsReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'simplifies render simple partial' do content = <<-EOF <%= render partial: 'sidebar...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb
Ruby
mit
4,169
main
3,494
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe MoveFinderToNamedScopeReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'moves finder to named_scope' do content = <<-EOF class PostsController < ActionCo...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb
Ruby
mit
4,169
main
4,975
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseMultipartAlternativeAsContentTypeOfEmailReview do let(:runner) { Core::Runner.new(prepares: Prepares::GemfilePrepare.new, reviews: described_class.new) } before { allow(Core::Runner).to receive(...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb
Ruby
mit
4,169
main
2,843
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe OveruseRouteCustomizationsReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'overuses route customizations' do content = <<-EOF RailsBestpracticesCom::App...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
Ruby
mit
4,169
main
2,616
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe SimplifyRenderInControllersReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'simplifies render action view' do content = <<-EOF def edit render...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb
Ruby
mit
4,169
main
17,362
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe RemoveUnusedMethodsInControllersReview do let(:runner) do Core::Runner.new( prepares: [Prepares::ControllerPrepare.new, Prepares::RoutePrepare.new], reviews: described_class.ne...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb
Ruby
mit
4,169
main
4,012
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseTurboSprocketsRails3Review do let(:runner) { Core::Runner.new(prepares: Prepares::GemfilePrepare.new, reviews: described_class.new) } it 'uses turbo-sprockets-rails3' do content = <<~EOF...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb
Ruby
mit
4,169
main
3,857
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe IsolateSeedDataReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } context 'create' do it 'isolates seed data' do content = <<-EOF class CreateRole...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb
Ruby
mit
4,169
main
4,617
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe RemoveUnusedMethodsInHelpersReview do let(:runner) do Core::Runner.new( prepares: [Prepares::ControllerPrepare.new, Prepares::HelperPrepare.new], reviews: described_class.new(e...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/hash_syntax_review_spec.rb
Ruby
mit
4,169
main
2,296
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe HashSyntaxReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'finds 1.8 Hash with symbol' do content = <<-EOF class User < ActiveRecord::Base CON...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb
Ruby
mit
4,169
main
3,558
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe KeepFindersOnTheirOwnModelReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'keeps finders on thier own model' do content = <<-EOF class Post < ActiveReco...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb
Ruby
mit
4,169
main
3,420
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe ReplaceComplexCreationWithFactoryMethodReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'replaces complex creation with factory method' do content = <<-EOF ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/use_model_association_review_spec.rb
Ruby
mit
4,169
main
2,634
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe UseModelAssociationReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'uses model association for instance variable' do content = <<-EOF class PostsControl...