In this project, I build a linter for Ruby that can detect some errors within your ruby code according to ruby syntax rules.
This project is part of the Microverse curriculum in Ruby module!
Explore the docs »
View Demo
Report Bug
Request Feature
The project consists of four code files
- The 'bin' folder
- main The main is the executable file that controls lint logic.
- The 'lib' folder
-
error_check.rb This class checks for mistakes within the code. Different methods are used to do this checks.
-
test.rb This short program is used to test our small linting program and see how it responds when a file is passed for error checks.
-
my_test.rb This medium program is used to test our small 'linting' program and see how it responds when a file is passed for error checks.
- clone the project and add the file or files to be linted in the project directory.
- excecute the main.rb file inside bin/main.
- Specify the path to the file when prompted (lib/my_test.rb for example).
- The ruby file will run only if the path given is correct!
- The Rspec test cases reside in example_spec.rb file in the spec folder.
- To run the test cases, type (rspec spec/example_spec.rb) in your terminal.
- It detects trailing space(s) at the end of each line
def show_info
puts 'checks a trailing space'|
end
def show_info |
puts 'checks a trailing space' |
end
- Operator = should be surrounded by a single space
def show_info(\*args)
first_name = 'John'
last_name = 'Doe'
end
def show_info(\*args)
first_name = 'John'
last_name = 'Doe'
end
- Prefer single-quoted strings when you don't have string interpolation or special symbols
def show_info(\*args)
first_name = 'John'
puts "My name is #{first_name}!"
end
def show_info(\*args)
first_name = "John"
puts "My name is John!"
end
- It detects wrong indentation space
class TheTest
def initialize(*args)
@first_name = args[0]
@last_name = args[1]
end
end
class TheTest
def initialize(*args)
@first_name = args[0]
@last_name = args[1]
end
end
- Check for empty line withing your code and make sure the necessary empty line is not more than 1
class TheTest
def initialize(*args)
@first_name = args[0]
@last_name = args[1]
end
def show_info
puts @first_name + ' ' + @last_name
end
end
class TheTest
def initialize(*args)
@first_name = args[0]
@last_name = args[1]
end
def show_info
puts @first_name + ' ' + @last_name
end
end
- Clone the project
https://github.com/jstloyal/Ruby_Capstone.git
- Run the Application
This project was built using these technologies.
- Ruby
- Rubocop
- VsCode
- RSpec
- Git-Flow
You can watch how to use the linter here: []
👤 Author
## Adetayo Sunkanmi
- Github: @jstloyal
- Twitter: @jstloyalty
- Linkedin: Adetayo Sunkanmi
- E-mail: jstloyalty@gmail.com
📝 This project is MIT licensed.