All Projects → covermymeds → Rubocop Thread_safety

covermymeds / Rubocop Thread_safety

Licence: mit

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Rubocop Thread safety

Scantron
A distributed nmap / masscan scanning framework complete with an API client for automation workflows
Stars: ✭ 542 (+594.87%)
Mutual labels:  scanning
Rubocop Packaging
A RuboCop extension focused on enforcing upstream best practices and coding conventions.
Stars: ✭ 29 (-62.82%)
Mutual labels:  rubocop
Meowcop
A RuboCop configuration focusing Lint. Recommended by Sider
Stars: ✭ 51 (-34.62%)
Mutual labels:  rubocop
Rubocop Rspec
Code style checking for RSpec files
Stars: ✭ 603 (+673.08%)
Mutual labels:  rubocop
Dracnmap
Dracnmap is an open source program which is using to exploit the network and gathering information with nmap help. Nmap command comes with lots of options that can make the utility more robust and difficult to follow for new users. Hence Dracnmap is designed to perform fast scaning with the utilizing script engine of nmap and nmap can perform various automatic scanning techniques with the advanced commands.
Stars: ✭ 861 (+1003.85%)
Mutual labels:  scanning
Rubocop Rake
A RuboCop plugin for Rake
Stars: ✭ 32 (-58.97%)
Mutual labels:  rubocop
Sweep
Fast and powerful Swift string scanning made simple
Stars: ✭ 485 (+521.79%)
Mutual labels:  scanning
Ama
"Ask Me Anything" with Rails 5.2 Application
Stars: ✭ 61 (-21.79%)
Mutual labels:  rubocop
Scanless
online port scan scraper
Stars: ✭ 875 (+1021.79%)
Mutual labels:  scanning
Burp Suite Error Message Checks
Burp Suite extension to passively scan for applications revealing server error messages
Stars: ✭ 45 (-42.31%)
Mutual labels:  scanning
Rails Style Guide
A community-driven Ruby on Rails style guide
Stars: ✭ 6,178 (+7820.51%)
Mutual labels:  rubocop
Sqliv
massive SQL injection vulnerability scanner
Stars: ✭ 840 (+976.92%)
Mutual labels:  scanning
Policial
Review pull requests for style guide violations
Stars: ✭ 36 (-53.85%)
Mutual labels:  rubocop
Rubocop Github
Code style checking for GitHub Ruby repositories
Stars: ✭ 559 (+616.67%)
Mutual labels:  rubocop
Esp8266 deauther
Affordable WiFi hacking platform for testing and learning
Stars: ✭ 9,312 (+11838.46%)
Mutual labels:  scanning
Multiscanner
Modular file scanning/analysis framework
Stars: ✭ 494 (+533.33%)
Mutual labels:  scanning
Burp Suite Software Version Checks
Burp extension to passively scan for applications revealing software version numbers
Stars: ✭ 29 (-62.82%)
Mutual labels:  scanning
Pronto Rubocop
Pronto runner for Rubocop, ruby code analyzer
Stars: ✭ 62 (-20.51%)
Mutual labels:  rubocop
Sane Scan Pdf
Sane command-line scan-to-pdf script on Linux with OCR and deskew support
Stars: ✭ 58 (-25.64%)
Mutual labels:  scanning
Nugetdefense
An MSBuildTask that checks for known vulnerabilities. Inspired by OWASP SafeNuGet.
Stars: ✭ 44 (-43.59%)
Mutual labels:  scanning

RuboCop::ThreadSafety

Thread-safety analysis for your projects, as an extension to RuboCop.

Installation and Usage

Installation into an application

Add this line to your application's Gemfile:

gem 'rubocop-thread_safety'

Install it with Bundler by invoking:

$ bundle

Add this line to your application's .rubocop.yml:

require: rubocop-thread_safety

Now you can run rubocop and it will automatically load the RuboCop Thread-Safety cops together with the standard cops.

Scanning an application without adding it to the Gemfile

Install the gem:

$ gem install rubocop-thread_safety

Scan the application for just thread-safety issues:

$ rubocop -r rubocop-thread_safety --only ThreadSafety,Style/GlobalVars,Style/ClassVars,Style/MutableConstant

Configuration

There are some added configuration options that can be tweaked to modify the behaviour of these thread-safety cops.

Correcting code for thread-safety

There are a few ways to improve thread-safety that stem around avoiding unsynchronized mutation of state that is shared between multiple threads.

State shared between threads may take various forms, including:

  • Class variables (@@name). Note: these affect child classes too.
  • Class instance variables (@name in class context or class methods)
  • Constants (NAME). Ruby will warn if a constant is re-assigned to a new value but will allow it. Mutable objects can still be mutated (e.g. push to an array) even if they are assigned to a constant.
  • Globals ($name), with the possible exception of some special globals provided by ruby that are documented as thread-local like regular expression results.
  • Variables in the scope of created threads (where Thread.new is called).

Improvements that would make shared state thread-safe include:

  • freeze objects to protect against mutation. Note: freeze is shallow, i.e. freezing an array will not also freeze its elements.
  • Use data structures or concurrency abstractions from concurrent-ruby, e.g. Concurrent::Map
  • Use a Mutex or similar to synchronize access.
  • Use ActiveSupport::CurrentAttributes
  • Use RequestStore
  • Use Thread.current[:name]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/covermymeds/rubocop-thread_safety.

Copyright

Copyright (c) 2016-2020 CoverMyMeds. See LICENSE.txt for further details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].