repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/cli.rb | lib/rails_best_practices/cli.rb | # frozen_string_literal: true
module RailsBestPractices
class CLI
# Run analyze with ruby code
# @param [Array] argv command argments
# @return [Boolean] return true, if there is no violation.
# @example
# RailsBestPractices::CLI.run(['-d', '-o', 'path/to/file'])
def self.run(argv)
op... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews.rb | lib/rails_best_practices/reviews.rb | # frozen_string_literal: true
require_rel 'reviews'
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares.rb | lib/rails_best_practices/prepares.rb | # frozen_string_literal: true
require_rel 'prepares'
module RailsBestPractices
module Prepares
class << self
def klasses
models + mailers + controllers
end
def models
@models ||= Core::Models.new
end
def model_associations
@model_associations ||= Core::Mod... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/colorize.rb | lib/rails_best_practices/colorize.rb | # frozen_string_literal: true
module RailsBestPractices
class Colorize
def self.red(message)
"\e[31m#{message}\e[0m"
end
def self.green(message)
"\e[32m#{message}\e[0m"
end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb | lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb | # 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:... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb | lib/rails_best_practices/reviews/needless_deep_nesting_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/hash_syntax_review.rb | lib/rails_best_practices/reviews/hash_syntax_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/not_rescue_exception_review.rb | lib/rails_best_practices/reviews/not_rescue_exception_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review all code to make sure we don't rescue Exception
# This is a common mistake by Java or C# devs in ruby.
#
# See the best practice details here https://rails-bestpractices.com/posts/2012/11/01/don-t-rescue-exception-rescue-... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/isolate_seed_data_review.rb | lib/rails_best_practices/reviews/isolate_seed_data_review.rb | # 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:
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/move_code_into_controller_review.rb | lib/rails_best_practices/reviews/move_code_into_controller_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a view file to make sure there is no finder, finder should be moved to controller.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/move-code-into-controller/
#
# Implementation:... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/check_save_return_value_review.rb | lib/rails_best_practices/reviews/check_save_return_value_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/move_code_into_helper_review.rb | lib/rails_best_practices/reviews/move_code_into_helper_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a view file to make sure there is no complex options_for_select message call.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/move-code-into-helper/
#
# TODO: we need a better s... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb | lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb | lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a controller file to make sure that complex model logic should not exist in controller, should be moved into a model.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/21/move-model-logic-in... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb | lib/rails_best_practices/reviews/remove_empty_helpers_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a helper file to make sure it is not an empty moduel.
#
# See the best practice details here https://rails-bestpractices.com/posts/2011/04/09/remove-empty-helpers/
#
# Implementation:
#
# Review process:
#... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_model_association_review.rb | lib/rails_best_practices/reviews/use_model_association_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# review a controller file to make sure to use model association instead of foreign key id assignment.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/19/use-model-association/
#
# Implemen... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/review.rb | lib/rails_best_practices/reviews/review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# A Review class that takes charge of reviewing one rails best practice.
class Review < Core::Check
# default url.
url '#'
# remember use count for the variable in the call or assign node.
#
# find the varia... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb | lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb | # 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/
#
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb | lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb | # 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/... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/law_of_demeter_review.rb | lib/rails_best_practices/reviews/law_of_demeter_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review to make sure not to avoid the law of demeter.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/the-law-of-demeter/
#
# Implementation:
#
# Review process:
# check a... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb | lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Check if method definition has parentheses around parameters.
#
# Review process:
# check def node in all files,
# if params node with values, but not wrapped by paren node,
# then it should use parentheses around ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb | lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Find out unused methods in helpers.
#
# Implementation:
#
# Review process:
# remember all method calls in helpers.
# if they are not called in views, helpers, or controllers
# then they are unused methods ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_before_filter_review.rb | lib/rails_best_practices/reviews/use_before_filter_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_observer_review.rb | lib/rails_best_practices/reviews/use_observer_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Make sure to use observer (sorry we only check the mailer deliver now).
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/use-observer/
#
# TODO: we need a better solution, any suggestio... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb | lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/check_destroy_return_value_review.rb | lib/rails_best_practices/reviews/check_destroy_return_value_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb | lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb | # 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,
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb | lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb | # 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/
#
#... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb | lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review model files to make sure finders are on their own model.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/23/keep-finders-on-their-own-model/
#
# Implementation:
#
# Review ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb | lib/rails_best_practices/reviews/simplify_render_in_views_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_scope_access_review.rb | lib/rails_best_practices/reviews/use_scope_access_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a controller to make sure to use scope access instead of manually checking current_user and redirect.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/20/use-scope-access/
#
# Imple... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/use_query_attribute_review.rb | lib/rails_best_practices/reviews/use_query_attribute_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb | lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb | lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb | # 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:
#
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/not_use_default_route_review.rb | lib/rails_best_practices/reviews/not_use_default_route_review.rb | # 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/
#
# ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb | lib/rails_best_practices/reviews/default_scope_is_evil_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb | lib/rails_best_practices/reviews/protect_mass_assignment_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb | lib/rails_best_practices/reviews/overuse_route_customizations_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review config/routes.rb file to make sure there are no overuse route customizations.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/22/overuse-route-customizations/
#
# Implementation:
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb | lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Find out unused methods in models.
#
# Implemenation:
#
# Review process:
# remember all method calls,
# at end, check if all defined methods are called,
# if not, non called methods are unused.
class R... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/move_code_into_model_review.rb | lib/rails_best_practices/reviews/move_code_into_model_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb | lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb | # frozen_string_literal: true
module RailsBestPractices
module Reviews
# Review a controller file to make sure there are no complex finder.
#
# See the best practice details here https://rails-bestpractices.com/posts/2010/07/14/move-finder-to-named_scope/
#
# Implementation:
#
# Review pr... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/always_add_db_index_review.rb | lib/rails_best_practices/reviews/always_add_db_index_review.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb | lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb | # 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/
#
# ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb | lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb | # 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:
#
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core_ext/erubis.rb | lib/rails_best_practices/core_ext/erubis.rb | # 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
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/inline_disables/comment_ripper.rb | lib/rails_best_practices/inline_disables/comment_ripper.rb | # frozen_string_literal: true
module RailsBestPractices
module InlineDisables
class CommentRipper < Ripper::SexpBuilder
attr_reader :comments
def initialize(*arg)
super
@comments = []
end
def on_comment(*arg)
# [sexp_type, statement, [lineno, column]] = super
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/inline_disables/inline_disable.rb | lib/rails_best_practices/inline_disables/inline_disable.rb | # frozen_string_literal: true
module RailsBestPractices
module InlineDisables
class InlineDisable < Core::Check
interesting_files ALL_FILES
url '#'
def initialize(*args)
super
@disabled_errors = []
end
def check(filename, content)
comments = CommentRipper.n... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/initializer_prepare.rb | lib/rails_best_practices/prepares/initializer_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/route_prepare.rb | lib/rails_best_practices/prepares/route_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/schema_prepare.rb | lib/rails_best_practices/prepares/schema_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/mailer_prepare.rb | lib/rails_best_practices/prepares/mailer_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/gemfile_prepare.rb | lib/rails_best_practices/prepares/gemfile_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/model_prepare.rb | lib/rails_best_practices/prepares/model_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/controller_prepare.rb | lib/rails_best_practices/prepares/controller_prepare.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/helper_prepare.rb | lib/rails_best_practices/prepares/helper_prepare.rb | # 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
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/prepares/config_prepare.rb | lib/rails_best_practices/prepares/config_prepare.rb | # 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
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/lexicals/remove_tab_check.rb | lib/rails_best_practices/lexicals/remove_tab_check.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/lexicals/long_line_check.rb | lib/rails_best_practices/lexicals/long_line_check.rb | # 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
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb | lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/checks_loader.rb | lib/rails_best_practices/core/checks_loader.rb | # 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) }
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/gems.rb | lib/rails_best_practices/core/gems.rb | # 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 ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/methods.rb | lib/rails_best_practices/core/methods.rb | # 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]... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/klasses.rb | lib/rails_best_practices/core/klasses.rb | # 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 }
... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/model_associations.rb | lib/rails_best_practices/core/model_associations.rb | # 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, ... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/controllers.rb | lib/rails_best_practices/core/controllers.rb | # frozen_string_literal: true
require_rel 'klasses'
module RailsBestPractices
module Core
# Controller classes.
class Controllers < Klasses; end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/routes.rb | lib/rails_best_practices/core/routes.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/models.rb | lib/rails_best_practices/core/models.rb | # frozen_string_literal: true
module RailsBestPractices
module Core
# Model classes.
class Models < Klasses; end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/mailers.rb | lib/rails_best_practices/core/mailers.rb | # frozen_string_literal: true
module RailsBestPractices
module Core
# Mailer classes.
class Mailers < Klasses; end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/model_attributes.rb | lib/rails_best_practices/core/model_attributes.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/helpers.rb | lib/rails_best_practices/core/helpers.rb | # frozen_string_literal: true
require_rel 'modules'
module RailsBestPractices
module Core
# Helper moduels.
class Helpers < Modules; end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/runner.rb | lib/rails_best_practices/core/runner.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/check.rb | lib/rails_best_practices/core/check.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/configs.rb | lib/rails_best_practices/core/configs.rb | # frozen_string_literal: true
module RailsBestPractices
module Core
class Configs < Hash; end
end
end
| ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/modules.rb | lib/rails_best_practices/core/modules.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
flyerhzm/rails_best_practices | https://github.com/flyerhzm/rails_best_practices/blob/2ef40880d12ff8ed5f516871133ec569df03b192/lib/rails_best_practices/core/error.rb | lib/rails_best_practices/core/error.rb | # 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... | ruby | MIT | 2ef40880d12ff8ed5f516871133ec569df03b192 | 2026-01-04T15:47:01.660067Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spec_helper.rb | spec_helper.rb | # This module is only used to check the environment is currently a testing env
module SpecHelper
end
require "coveralls"
Coveralls.wear! unless ENV["FASTLANE_SKIP_UPDATE_CHECK"]
require "webmock/rspec"
WebMock.disable_net_connect!(allow: 'coveralls.io')
require "fastlane"
UI = FastlaneCore::UI
unless ENV["DEBUG"]
... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/commands_generator_spec.rb | scan/spec/commands_generator_spec.rb | require 'scan/commands_generator'
describe Scan::CommandsGenerator do
let(:available_options) { Scan::Options.available_options }
describe ":tests option handling" do
def expect_manager_work_with(expected_options)
expect(Scan::Manager).to receive_message_chain(:new, :work) do |actual_options|
ex... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/error_handler_spec.rb | scan/spec/error_handler_spec.rb | require 'scan'
describe Scan do
describe Scan::ErrorHandler do
let(:log_path) { '~/scan.log' }
describe "handle_build_error" do
describe "when parsing parallel test failure output" do
it "does not report a build failure" do
expect(Scan).to receive(:config).and_return({})
ou... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/slack_poster_spec.rb | scan/spec/slack_poster_spec.rb | require 'scan'
require 'slack-notifier'
describe Scan::SlackPoster do
before do
# mock the network request part
allow_any_instance_of(Fastlane::Actions::SlackAction::Runner).to receive(:post_message).with(any_args)
end
describe "slack_url handling" do
describe "without a slack_url set" do
it "... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/test_command_generator_spec.rb | scan/spec/test_command_generator_spec.rb | describe Scan do
before(:all) do
options = { project: "./scan/examples/standard/app.xcodeproj" }
config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
@project = FastlaneCore::Project.new(config)
end
before(:each) do
@valid_simulators = "== Devices ==
-- iOS 10.0 -... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | true |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/test_result_parser_spec.rb | scan/spec/test_result_parser_spec.rb | describe Scan do
describe Scan::TestResultParser do
it "properly parses the xcodebuild output" do
output = "<?xml version='1.0' encoding='UTF-8'?>
<testsuites tests='2' failures='1'>
<testsuite name='appTests' tests='2' failures='1'>
<testcase classname='appTests' name='testExample'>
... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/xcpretty_reporter_options_generator_spec.rb | scan/spec/xcpretty_reporter_options_generator_spec.rb | describe Scan do
describe Scan::XCPrettyReporterOptionsGenerator, requires_xcodebuild: true do
before(:all) do
options = { project: "./scan/examples/standard/app.xcodeproj" }
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
Scan.cache[:temp_junit_report]... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/runner_spec.rb | scan/spec/runner_spec.rb | require 'scan'
describe Scan do
describe Scan::Runner do
describe "handle_results" do
before(:each) do
mock_slack_poster = Object.new
allow(Scan::SlackPoster).to receive(:new).and_return(mock_slack_poster)
allow(mock_slack_poster).to receive(:run)
mock_test_command_generato... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/detect_values_spec.rb | scan/spec/detect_values_spec.rb | describe Scan do
describe Scan::DetectValues do
describe 'Xcode project' do
describe 'detects FastlaneCore::Project' do
it 'with no :project or :package_path given', requires_xcodebuild: true do
# Mocks input from detect_projects
project = FastlaneCore::Project.new({
... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/spec/spec_helper.rb | scan/spec/spec_helper.rb | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false | |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan.rb | scan/lib/scan.rb | require_relative 'scan/manager'
require_relative 'scan/options'
require_relative 'scan/runner'
require_relative 'scan/detect_values'
require_relative 'scan/test_command_generator'
require_relative 'scan/xcpretty_reporter_options_generator.rb'
require_relative 'scan/test_result_parser'
require_relative 'scan/error_handl... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/test_command_generator.rb | scan/lib/scan/test_command_generator.rb | require_relative 'xcpretty_reporter_options_generator'
module Scan
# Responsible for building the fully working xcodebuild command
class TestCommandGenerator
def generate
parts = prefix
parts << Scan.config[:xcodebuild_command]
parts += options
parts += actions
parts += suffix
... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/options.rb | scan/lib/scan/options.rb | require 'fastlane_core/configuration/config_item'
require 'fastlane/helper/xcodebuild_formatter_helper'
require 'credentials_manager/appfile_config'
require_relative 'module'
# rubocop:disable Metrics/ClassLength
module Scan
class Options
def self.verify_type(item_name, acceptable_types, value)
type_ok = [... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | true |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/slack_poster.rb | scan/lib/scan/slack_poster.rb | require 'fastlane/action'
require 'fastlane/actions/slack'
require 'fastlane_core/configuration/configuration'
require_relative 'module'
module Scan
class SlackPoster
def run(results)
return if Scan.config[:skip_slack]
return if Scan.config[:slack_only_on_failure] && results[:failures] == 0
re... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/detect_values.rb | scan/lib/scan/detect_values.rb | require 'fastlane_core/device_manager'
require 'fastlane_core/project'
require 'pathname'
require 'set'
require_relative 'module'
module Scan
# This class detects all kinds of default values
class DetectValues
PLATFORMS = {
'iOS' => { simulator: 'iphonesimulator', name: 'com.apple.platform.iphoneos' },
... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/test_result_parser.rb | scan/lib/scan/test_result_parser.rb | require_relative 'module'
module Scan
class TestResultParser
def parse_result(output)
unless output
return {
tests: 0,
failures: 0
}
end
# e.g. ...<testsuites tests='2' failures='1'>...
matched = output.scan(/<testsuites\b(?=[^<>]*\s+tests='(\d+)')... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/commands_generator.rb | scan/lib/scan/commands_generator.rb | require 'commander'
require 'fastlane_core/configuration/configuration'
require 'fastlane_core/ui/help_formatter'
require_relative 'module'
require_relative 'manager'
require_relative 'options'
HighLine.track_eof = false
module Scan
class CommandsGenerator
include Commander::Methods
def self.start
n... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/xcpretty_reporter_options_generator.rb | scan/lib/scan/xcpretty_reporter_options_generator.rb | require_relative 'module'
module Scan
class XCPrettyReporterOptionsGenerator
SUPPORTED_REPORT_TYPES = %w(html junit json-compilation-database)
def self.generate_from_scan_config
self.new(Scan.config[:open_report],
Scan.config[:output_types],
Scan.config[:output_files] || ... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/error_handler.rb | scan/lib/scan/error_handler.rb | require_relative 'module'
module Scan
# This classes methods are called when something goes wrong in the building process
class ErrorHandler
class << self
# @param [String] The output of the errored build
# This method should raise an exception in any case, as the return code indicated a failed bui... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/runner.rb | scan/lib/scan/runner.rb | require 'open3'
require 'fileutils'
require 'terminal-table'
require 'shellwords'
require 'fastlane_core/env'
require 'fastlane_core/device_manager'
require_relative 'module'
require_relative 'xcpretty_reporter_options_generator'
require_relative 'test_result_parser'
require_relative 'slack_poster'
require_relative 't... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/manager.rb | scan/lib/scan/manager.rb | require 'fastlane_core/print_table'
require_relative 'module'
require_relative 'runner'
module Scan
class Manager
attr_accessor :plist_files_before
def work(options)
Scan.config = options # we set this here to auto-detect missing values, which we need later on
unless options[:derived_data_path].... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/scan/lib/scan/module.rb | scan/lib/scan/module.rb | require 'fastlane_core/helper'
require 'fastlane/boolean'
require_relative 'detect_values'
module Scan
class << self
attr_accessor :config
attr_accessor :project
attr_accessor :cache
attr_accessor :devices
def config=(value)
@config = value
DetectValues.set_additional_default_valu... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/rubocop/is_string_usage.rb | rubocop/is_string_usage.rb | require 'rubocop'
module RuboCop
module Cop
module Lint
class IsStringUsage < RuboCop::Cop::Cop
MSG = 'is_string key in used in FastlaneCore::ConfigItem. Replace with `type: <Integer|Float|String|Boolean|Array|Hash>`'.freeze
def on_hash(node)
pairs = node.pairs
return i... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/rubocop/fork_usage.rb | rubocop/fork_usage.rb | require 'rubocop'
module RuboCop
module CrossPlatform
class ForkUsage < RuboCop::Cop::Cop
MSG = "Using `fork`, which does not work on all platforms. Wrap in `if Process.respond_to?(:fork)` to silence.".freeze
def_node_matcher :bad_fork, <<-PATTERN
(send _ :fork)
PATTERN
def_node... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/rubocop/missing_keys_on_shared_area.rb | rubocop/missing_keys_on_shared_area.rb | require 'rubocop'
module RuboCop
module Lint
class MissingKeysOnSharedArea < RuboCop::Cop::Cop
MISSING_KEYS_MSG = "Found %<key>s in 'SharedValues' but not in 'output' method. Keys in the 'output' method: %<list>s".freeze
MISSING_OUTPUT_METHOD_MSG = "There are declared keys on the shared area 'SharedV... | ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.