The project is used to create a linter that can check for error messages inside a code. This check can be on any ruby file. Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. The analysis performed by lint-like tools can also be performed by an optimizing compiler, which aims to generate faster code
This ruby linter currently detects for following errors:
- Empty lines in code
- Line length
- Trailing white spaces
- Empty line after
end
- Empty line at the start of the file
- File not starting from
def , class or module
- Brackets not closed properly.
- Pranthesis not closed properly.
- Curly brackets not closed properly.
These are some of the examples of how ruby will see if the code is good or bad:
def normal
puts "Hello"
end
def hello
puts "Hello"
end
def normal
puts "Hello"
end
def hello
puts "Hello"
end
def hello
puts "This is a very long string with more than 100 characters in one single string. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
end
def hello
puts "this is a short string with fewer characters"
end
def normal
puts "Hello"
end
def normal
puts "Hello"
end
def normal
puts "Hello"
end
def normal
puts "Hello"
end
puts "Hello"
puts "Hello"
puts "First line without a function"
def normal
puts "First line with a function"
end
array = [ 1,2,3,4
array = [ 1,2,3,4]
def normal hash)
hash.each{ |v,i| puts "Hello #{v}" }
end
hash = {:foo=>0, :bar=>1, :baz=>2}
puts normal(hash
def normal(hash)
hash.each{ |v,i| puts "Hello #{v}" }
end
hash = {:foo=>0, :bar=>1, :baz=>2}
puts normal(hash)
def normal(hash)
hash.each{ |v,i| puts "Hello #{v" }
end
hash = :foo=>0, :bar=>1, :baz=>2}
puts normal(hash)
def normal(hash)
hash.each{ |v,i| puts "Hello #{v}" }
end
hash = {:foo=>0, :bar=>1, :baz=>2}
puts normal(hash)
- Ruby
π€ Uzair
- LinkedIn: LinkedIn
- GitHub: @githubhandle
To get a local copy of this project follow the steps below:
Use git clone https://github.com/uzairali19/linter-ruby.git
to clone the branch directly to your machine
- Run
bundle install
- Run
rubocop
- Fix linter errors
- IMPORTANT NOTE: feel free to research auto-correct options for Rubocop if you get a flood of errors but keep in mind that correcting style errors manually will help you to make a habit of writing a clean code!
- Navigate the project, you can open it with VScode or any other code editor of choice
- Happy coding!
- Run
bundle install
- Run
rake test
- See the spec log on the console to check the results
- Run
bundle install
- Run
rake rspec
- See the spec log on the console to check the results
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page
Give a βοΈ if you like this project!
This project is copyright protected, Feel free to contact the authors to collaborate