Giter Club home page Giter Club logo

refactoringwithrubocop's Introduction

Rubocop: The Future of Standards Enforcement

Skill Level: Beginner - Intermediate

Time Limit: 45 minutes

This is a challenge for learning Rubocop and how to do things the 'ruby' way. You will also learn about refactoring and why it's important.

Instructions

You have been tasked to clean up Gem City. Luckily, your boss has paired you up with the newest advancement in code enforcement technology, Rubocop.

  1. Install the required gems
gem install bundler
bundle install
  1. Run rspec with rspec gem_city_spec.rb and then get a feel for the code that's passing.
  2. Run rubocop with rubocop or rubocop <filename> and see what's failing.
  3. Correct all rubocop errors.
  4. Rerun the tests and rubocop. If there are no complaints, congratulations you've successfully cleaned up the streets of Gem City. There are 3 lines in the rspec file that you can change, leave the rest.

Bonus: Write the city demographics feature

  • Uncomment the block of code at the end of the spec file
  • Write the code to make the test pass.
  • Run rubocop and then make the corrections.
  • Rerun your test. If it passes, you've successfully refactored your function.

Advanced Challenge: See how short you can make the GemCity class while still passing Rubocop and rspec tests

Things to think about

  • Why would you want to follow standards?
  • What is the purpose of refactoring, if it works, why refactor?
  • How can refactoring help us expand our code?
  • The bonus challenge follows a process called Red, Green, Refactor.

Resources

refactoringwithrubocop's People

Contributors

paradime avatar trueheart78 avatar

Watchers

James Cloos avatar Austen Madden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.