/rubocop

The whole idea of this project is to build my own version on a linter build in ruby to check ruby code

Primary LanguageRuby

Rubocop

This project was built in ruby to check ruby code, it is a linters for beginners, it provides feedback about errors or warning in code little by little. It was developed following the best practices

In this project we are looking for the following errors:

  • Wrong indentation
  • Trailing spaces
  • New line errors
  • Empty files
  • Last empty line

linter1

Go Live

Built With

  • Ruby

Prerequisites

  • Installed Ruby

To get a local copy up and running follow these simple example steps.

Go to git clone git@github.com:Mhdez221993/my_lin.git

Install RSpec

To run the tests locally :

  • To instal RSpec for testing please run the following command on your terminal:

    gem install rspec

Run tests

To test the code, run rspec from the root of the folder using the terminal.

Instructions

  1. Open your terminal:

    • On Windows => Win + R
    • On Linux => ctrl + alt + T
    • On Mac => Control + Option + Shift + T
  2. In your terminal run:

    • ./bin/main.rb this will inspect all the files in the actual directory
  3. you can provide a path to test a specific file in the same directory or outside by typing:

    • ./bin/main.rb some_file_in_my_directory.rb
    • ./bin/main.rb ../../some_file.rb

Good and bad code examples

Wrong indentation

//Good Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

//Bad Code

def call_check_last_line
check_last_line unless File.zero?(file)
end

Trailing spaces

//Good Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

//Bad Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

New line errors

//Good Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

def call_check_last_line
  check_last_line unless File.zero?(file)
end

//Bad Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end
def call_check_last_line
  check_last_line unless File.zero?(file)
end

Last empty line

//Good Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

def call_check_last_line
  check_last_line unless File.zero?(file)
end


//Bad Code

def call_check_last_line
  check_last_line unless File.zero?(file)
end

def call_check_last_line
  check_last_line unless File.zero?(file)
end

Authors

👤 Moises Hernandez Coronado

Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • To my coding partner who helped me through all the work
  • To my Stand Up Team who kept my morale up!