This is a simple application to analyze Ruby code styling error aka Linter
This is the Ruby-Capstone Project. Main goal for this project was to build My own Linter Using Ruby language. It is a simple application to analyze Ruby code behavior and checks if the coding style is good or bad if it's bad then it will show the errors.
- About The Project
- Types of Inspections
- Built with
- Comparision of Good and Bad code
- Getting Started
- License
- Authors
- Acknowledgements
I have used following types of inspections to analyze style error
- File Names
- Class Names
- Method Names
- Trailing Space
- Space around the operators
- Maximum line length
- Maximum file length
- leading empty line
- trailing empty line
- double space
# bad File Name
FileName
# Good File Name
file_name
# Bad Class Name
class class_name
end
# Good class Name
class ClassName
end
# Bad Method Name
def MethodName| <-- Use only snake case
end
# Good Method Name
def method_name
end
# bad
sum=1+2
# good
sum = 1 + 2
# bad
def method_name |<-- Trailing space detected
end
# good
def method_name|
end
# bad
class ClassName
end
| <-- only one empty line require
# good
class ClassName
end
|
# bad
3 class ClassName
~~~~~~~~~~~~~~
~~~~~~~
150 end | <-- should be less than 118 lines
# good
3 class ClassName
~~~~~~~
~~~~~~~
90 end
# bad
3 puts 'This is line ~~~~~~~~~~~' | <-- total characters in line > 80
# good
3 puts ' This is line ~~' | <-- Total characters in line < 80
# bad
1 | <-- Empty line not rquired
4 class ClassName
~~~~~~
30 end
# good
1 require 'file_name'
3 class ClassName
~~~~~
30 end
- Ruby
To get a local copy up and running follow these simple steps.
- clone This repository by using the following command on your local PC:
git clone https://github.com/Div685/Ruby-Linter.git
- After cloning navigate to the folder, you will need to install some of the required dependencies using the following command:
bundle install
- To use the linter run the following command in the terminal
bin/main ./test_file/test_lint_file.rb
To test the code with rspec.
- install rspec using
gem install rspec
- run
rspec
orrspec --format doc
on your terminal to test the code .
👤 Divyesh Patel
- GitHub: @Div685
- Twitter: @div_685
- LinkedIn: Divyesh Patel
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
This project is MIT licensed.
Give a ⭐️ if you like this project!
followed Ruby style guide and selected some of the inspection to analyze the linter file