Skip to content

This is Ruby linter which has been written in Ruby language to check different errors

License

Notifications You must be signed in to change notification settings

AbdumurodovaZulfizar/ruby-linter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capstone Project - Ruby linter

Game description📄

This ruby linter checks for the following errors/warnings:

  1. Check for trailing spaces
  2. Check for the wrong indentation
  3. Check for missing/unexpected tags i.e. '( )', '[ ]', and '{ }'
  4. Check missing/unexpected end
  5. Check empty line error
  6. Check class names for CamelCase format
  7. Check module names for CamelCase format
  8. Check line length
  9. Check space before methods

Below you can see good, bad and empty code examples and their test results on the console

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

Console uotput

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

Console uotput

The empty file shows a warning to the user!👐

# Emty Code






Console uotput

Content

Requirements

  • gem install colorize
  • gem install bundler

Getting started

  • 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

RSpec test Instructions

  1. To test this project install RSpec, for it boot up your terminal and punch in `gem install rspec` to install RSpec.
  2. `cd` into ruby-linter project directory
  3. Type `rspec`

Built With

  • Ruby Language
  • Git  Git
  • GitHub  GitHub
  • Visual Studio Code  VScode

Author

👩🏻‍💼 Zulfizar Abdumurodova

Dependencies

Ruby 3.0.1

Contributing

Contributions, issues and feature requests are welcome!

You can do it on issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • Microverse for international opportunities.
  • Special thanks to all code reviewers.

📝 License

Copyright 2021 Zulfizar Abdumurodova

  • MIT for this project.

About

This is Ruby linter which has been written in Ruby language to check different errors

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages