This ruby linter checks for the following errors/warnings:
- Check for trailing spaces
- Check for the wrong indentation
- Check for missing/unexpected tags i.e. '( )', '[ ]', and '{ }'
- Check missing/unexpected end
- Check empty line error
- Check class names for CamelCase format
- Check module names for CamelCase format
- Check line length
- Check space before methods
Good code passes this test successfully!👍
# Good Code
class Board
attr_reader :sets, :grid
attr_accessor :selections
def initialize
@sets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
@grid = "+---+---+---+\n| 1 | 2 | 3 |\n+---+---+---+\n| 4 | 5 | 6 |\n+---+---+---+\n| 7 | 8 | 9 |\n+---+---+---+"
@selections = []
end
def insert(number, sym)
@grid[@grid.index(number.to_s)] = sym
end
end
Bad code passes this test unsuccessfully!👎
# Bad Code
class board
attr_reader :sets, :grid
attr_accessor :selections
def initialize
@sets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
@grid = "+---+---+---+\n| 1 | 2 | 3 |\n+---+---+---+\n| 4 | 5 | 6 |\n+---+---+---+\n| 7 | 8 | 9 |\n+---+---+---+"+ "this line is longer than 120 characters"
@selections = []]
end
def insert(number, sym
@grid[@grid.index(number.to_s)] = sym
end
end
end
The empty file shows a warning to the user!👐
# Emty Code
- Necessary requirements
- Getting started
- RSpec test Instructions
- Built With
- Getting Started
- Dependencies
- Contributing
- Acknowledgments
- Author
- License
- gem install colorize
- gem install bundler
- firstly install all requirements above
- open your terminal
- clone the repository
$ git clone https://github.com/AbdumurodovaZulfizar/ruby-linter.git
- cd ruby-linter
- open the downloaded repository with your code editor.
- Run the command
$ ruby ./bin/main.rb ./folder/your_file.rb
For instance, to see run good_code write on terminal :ruby ./bin/main.rb ./example/good_code.rb
- To test this project install RSpec, for it boot up your terminal and punch in `gem install rspec` to install RSpec.
- `cd` into ruby-linter project directory
- Type `rspec`
👩🏻💼 Zulfizar Abdumurodova
- GitHub: Abdumurodova Zulfizar
- Twitter: Abdumurodova Zulfizar
- LinkedIn: Abdumurodova Zulfizar
Ruby 3.0.1
Contributions, issues and feature requests are welcome!
You can do it on issues page.
Give a ⭐️ if you like this project!
- Microverse for international opportunities.
- Special thanks to all code reviewers.
Copyright 2021 Zulfizar Abdumurodova
- MIT for this project.