New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bulletmark_repairer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulletmark_repairer

  • 0.1.7
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

BulletmarkRepairer

BulletmarkRepairer is an auto corrector for N+1 queries detected at runtime on Ruby on Rails application using Bullet and Parser.

Installation

Add this line to your application's Gemfile:

gem 'bulletmark_repairer', group: %w(development test)

Usage

Run rails server or rspec with REPAIR=1 to autocorrect when N+1 queries are caused.

REPAIR=1 rails server
REPAIR=1 rspec

How BulletmarkRepairer auto corrects

After receiving Bullet's N+1 notification, find the code that the instance variable is assigned and add includes to it.
Currently, only the controller directory is a candidate for auto correct.
(We plan to implement allow list in the future)
Also when N+1 occurs in the views, correct the controller.

Disclaimer

BulletmarkRepairer is NOT safe

You must check that auto corrects are correct before you commit.
For example, when the associations to include depends on the request parameters, human intervention is required.

def index
  # Required associations depend on the parameters
  @plays = Play.ransack(params[:q])
end
BulletmarkRepairer is NOT complete

You can check log/bulletmark_repairer.log for files where N+1 is detected but not auto corrected.
For example, the following cases are not supported as known cases currently:

def index
  # Multiple nested associations require `includes` though child associations are already included
  @plays = Play.includes(:actors)
  # expected correct
  @plays = Play.includes(:actors).includes({:actors=>{:company=>[:offices]}})
  # actual correct
  @plays = Play.includes(:actors).includes({:actors=>[:company]})
end

Configuration

To customize, add config/initializers/bulletmark_repairer.rb:

BulletmarkRepairer.configure do |config|
  # when you want to output log to Rails.logger
  config.logger = Rails.logger
  # when BulletmarkRepairer malfunctions, skip the file
  config.skip_file_list = %w[app/controllers/plays_controller.rb]
  # when you want to debug bulletmark_repairer's errors
  config.debug = true
end
  • logger: Injectable logger. In default Logger.new("#{Rails.root}/log/bulletmark_repairer.log")
  • skip_file_list: File list to skip to auto correct. In default []
  • debug: To raise BulletmarkRepairer's error or not. In default false

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/makicamel/bulletmark_repairer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the BulletmarkRepairer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 21 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc