This is a Ruby linter created using Ruby programming language. The aim of this linter is to make sure Ruby code is written well and improves the code.
The custom Ruby linter currently checks/detects for the following errors/warnings.
- check for missing/unexpected tags i.e. '( )', '[ ]', and '{ }'
- check missing/unexpected end
- check for trailing spaces
- check empty line error
Below are demonstrations of good and bad code for the above cases. I will use the pipe '|' symbol to indicate cursor position where necessary.
# Good Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Bad Code
class ErrorCheck
def initialize file_path)
@checker = FileReader.new((file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Good Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Bad Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
note where the cursor(|) is on the bad code
# Good Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Bad Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path) |
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Good Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
# Bad Code
class ErrorCheck
def initialize(file_path)
@checker = FileReader.new(file_path)
@errors = []
@keywords = %w[class def begin do if module unless case]
end
end
- Ruby
- Rspec
To get a local copy of the repository please run the following commands on your terminal:
$ cd <folder>
$ git clone https://github.com/HillaryOkello/ruby-linter.git
To check for errors on a file:
$ bin/main test.rb
👤 Hillary Okello
- Github: @HillaryOkello
- Twitter: @kellyhillary4
- Linkedin: HillaryOkello
Contributions, issues and feature requests are welcome!
Give a ⭐️ if you like this project!