Codecast: Rubocop install and initial setup смотреть онлайн
In this codecast, we install and set up the Ruby code style checker RuboCop for use with Visual Studio Code.
RuboRoadPirate, er, RuboCop is a code style checker and linter for the Ruby programming language. Unlike government cops, RuboCop provides for enforcement of a voluntary and configurable set of standards. Code linting can improve the health of your codebase, help you and your collaborators maintain your project more easily, and help identify code that is ambiguous or buggy.
In the context of this video, we have Ruby installed (via RVM, see our video Install RVM and Ruby with Troubleshooting if you need help https://youtu.be/h-JBRJH8W7A) but don't have any of the RuboCop gems installed. We do have a .rubocop.yml file in the home directory of the statelesscode Ubuntu user, which RuboCop will use if there isn't a .rubocop.yml file in the root directory of the project it is attempting to scan.
In addition to core RuboCop, there are other optional sub-gems that you can include if they are applicable for your project:
- RuboCop Rails: A RuboCop extension focused on enforcing Rails best practices and coding conventions. https://rubygems.org/gems/rubocop-rails
- RuboCop Performance: A collection of RuboCop cops to check for performance optimizations in Ruby code. https://rubygems.org/gems/rubocop-performance
- RuboCop Rake https://rubygems.org/gems/rubocop-rake A RuboCop plugin for Rake
Testing framework extensions (only include the one of the test suite you're using for a given project)
- RuboCop RSpec: Code style checking for RSpec files. A plugin for the RuboCop code style enforcing & linting tool. https://rubygems.org/gems/rubocop-rspec
- RuboCop Minitest: A RuboCop extension focused on enforcing Minitest best practices and coding conventions. https://rubygems.org/gems/rubocop-minitest
There are other RuboCop related plugins like the Shopify-specific styles, RuboCop gems for GraphQL-related code, or even Node-related code. Go to https://rubygems.org and search for "rubocop".
In order for RuboCop to execute, we need to have consistency between the gems mentioned in the configuration file and the set of installed gems. If you get an error about requiring other RuboCop gems to be installed (like we encounter in this video), you can either remove them from the configuration file or install the required gem(s). In our case, we choose to install the missing gems when we encounter errors about them.
After that, we need to rename some outdated cop names in our configuration file. Once we do that we have a bunch of warnings on new cops that are not enabled. In this video, we add the missing cops to the .rubocop.yml file, but if you check out subsequent videos like "Change RuboCop Config to Enable New Cops By Default for a Rails Application", we change our configuration to enable new cops by default and only put non-default behavior in our configuration files.
This video covers:
00:00:10 Introduction
00:01:08 Install the RuboCop gem via the command line
00:01:41 Attempt to run on a directory with Ruby code in it. Errors out. Install rubocop-performance separately
00:02:36 Another error. Install rubocop-rails separately
00:03:05 Yet another error. Remove obsolete configuration from .rubocop.yml file in home directory
00:08:15 Try running again after modifying the configuration. Now we have violations being reported.
00:09:28 Take a look at warnings in the Visual Studio Code extension
00:10:23 Add new cops to configuration file to get rid of warnings
00:15:40 Open a terminal in Visual Studio Code and see the violations in the problems tab
#ruby #RuboCop #linting #RubyStyleGuide #RoboCop #config #RuboRoadPirate #rails #rspec #minitest #rake
The documentation for Rubocop can be found at https://rubocop.org/
NOTE: This was one of the first ever videos we published. As we use RuboCop more, there has been a bit of an evolution. Almost all of our hundreds of Ruby videos interact with RuboCop at some point, but we have links below to videos we've done where RuboCop is a primary subject Check out our other RuboCop related videos.
- Codecast: Create a RubyGem 03: Set up RuboCop and flesh out the README https://youtu.be/Iz_Wl-IDL-c
- Codecast: Create a RubyGem 09: Fix RuboCop issues and release a patch version https://youtu.be/2tw6ozMgTpQ
- Codecast: Create a RubyGem 27: Add Rubocop to Github Actions https://youtu.be/2tw6ozMgTpQ
- Update Ruby then Add RuboCop to a Rails Project https://youtu.be/5MbY5k5Wk68
- Change RuboCop Config to Enable New Cops By Default for a Rails Application https://youtu.be/J8QvGnn-wso
- Create a RubyGem 93: Refactor RuboCop to Enable New Cops by Default for the Gem https://youtu.be/wyZTKXMx8lg
This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Codecast: Rubocop install and initial setup» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.