This is a simple Ruby linter, used to improve code quality and readability.
You're working with Ruby and not sure what the best practices are?? Lintertin will help you. You can test a single file, and also you can test all the files that exist in the root directory by using this linter.
- Built With
- Getting Started
- Good and Bad examples
- Author
- π€ Contributing
- Show your support
- Acknowledgments
- Ruby
- Rubocop: as a linter
- RSpec: as a tester
To get a local copy up and running follow these simple example steps.
You should have Ruby installed on your machine.
Open your terminal, type git clone https://github.com/martinnajjar12/lintertin.git
and hit Enter to download this repository.
- At first, make sure that you have
bundler
installed on your machine. Again in your terminal type the commandbundler -v
. If a version showed up, skip the next step, if not please continue. - Type the command
gem install bundler
and hit Enter to install bundler on your machine. - Now you're ready to start! Type in your terminal
bundle install
to get the required dependencies to run this linter.
Follow these steps to scan your files:
-
Clone this repository as explained here
-
Put the files you want to scan in the root directory of this project as shown below (like
for_test.rb
file): -
Now you can simply run the command
bin/lintertin
in your terminal to check all the Ruby files that exist in the root directory, orbin/lintertin <the name of the file you want to scan>
if you want to scan a specific file.
You can test the project with RSpec! Simply type rspec
in your terminal to see the test results. Make sure to do this step after completing the install section
Take a look at the cops Lintertin warn you about:
Lintertin checks if there is a trailing space at the end of the line:
Bad Example:
class ForTest
'def method '
end
end
Good Example
class ForTest
'def method'
end
end
Lintertin checks if the lines are correctly indented:
Bad Example:
class ForTest
def method
end
end
Good Example
class ForTest
def method
end
end
Lintertin checks if there's an unwanted empty line after a certain keyword:
Bad Example:
class ForTest
def method
end
end
Good Example
class ForTest
def method
end
end
Lintertin checks if there's no empty line at the end of the file:
Bad Example:
class ForTest
def method
end
end
Good Example
class ForTest
def method
end
end
Consider the following examples:
Lintertin checks if there is a missing parenthesis:
Bad Example:
class ForTest
def method(param
end
end
Good Example
class ForTest
def method(param)
end
end
Lintertin checks if there is a missing curly brace:
Bad Example:
class ForTest
def method(array)
array.each { |n| puts n
end
end
Good Example
class ForTest
def method(array)
array.each { |n| puts n }
end
end
Lintertin checks if there is a missing bracket:
Bad Example:
class ForTest
def method(array)
puts array[3
end
end
Good Example
class ForTest
def method(array)
puts array[3]
end
end
Lintertin checks if the file has a missing pipe or a space before or after the pipe.
Lintertin checks if there is an unwanted space before or after the pipe:
Bad Example:
class ForTest
def method(array)
array.each do |elem |
end
end
end
Good Example
class ForTest
def method(array)
array.each do |elem|
end
end
end
Lintertin checks if there is a missing pipe:
Bad Example:
class ForTest
def method(array)
array.each do |elem
end
end
end
Good Example
class ForTest
def method(array)
array.each do |elem|
end
end
end
Warning: If there's a space before or after the pipe, then it will not check for a missing one.
Lintertin checks if there's a missing end
or an extra end
:
Lintertin checks if there's a missing end
:
Bad Example
class ForTest
def method
end
Good Example
class ForTest
def method
end
end
Lintertin also checks if there's an extra end
:
Bad Example
class ForTest
def method
end
end
end
Good Example
class ForTest
def method
end
end
Warning: This linter doesn't work with the inline if
and inline unless
!! For instance:
return 'something' if I'm_true\n
return 'something' unless I'm_true
π€ Martin Najjar
- GitHub: Martin Najjar
- Twitter: Martin Najjar
- LinkedIn: Martin Najjar
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a βοΈ if you like this project!
- Built as a capstone project for Ruby section in Microverse
- Inspired by the idea of Rubocop
This project is MIT licensed.