Skip to content

A linter developed in Ruby which detects some errors within ruby code. This is a beginner linter template which can be further improved.

License

Notifications You must be signed in to change notification settings

jstloyal/Ruby_Capstone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby_Capstone

In this project, I build a linter for Ruby that can detect some errors within your ruby code according to ruby syntax rules.

Contributors Forks Stargazers Issues


Microverse Logo

Ruby Linter

This project is part of the Microverse curriculum in Ruby module!
Explore the docs »

View Demo Report Bug Request Feature

Table of Contents

About The Project

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.

How to run the linter

  • 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!

Automated Test

  • 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.

What my ruby linter checks

Check trailing space

  • It detects trailing space(s) at the end of each line

good

  def show_info
    puts 'checks a trailing space'|
  end

bad

  def show_info |
    puts 'checks a trailing space' |
  end

Check space(s) surrounding the (=) operator

  • Operator = should be surrounded by a single space

good

  def show_info(\*args)
    first_name = 'John'
    last_name = 'Doe'
  end

bad

  def show_info(\*args)
    first_name  = 'John'
    last_name =  'Doe'
  end

Check for double quotes (") around strings

  • Prefer single-quoted strings when you don't have string interpolation or special symbols

good

  def show_info(\*args)
    first_name = 'John'
    puts "My name is #{first_name}!"
  end

bad

  def show_info(\*args)
    first_name = "John"
    puts "My name is John!"
  end

Check indentation

  • It detects wrong indentation space

good

  class TheTest
    def initialize(*args)
      @first_name = args[0]
      @last_name = args[1]
    end
  end

bad

    class TheTest
    def initialize(*args)
      @first_name = args[0]
      @last_name = args[1]
    end
  end

Check for empty line

  • Check for empty line withing your code and make sure the necessary empty line is not more than 1

good

  class TheTest
    def initialize(*args)
      @first_name = args[0]
      @last_name = args[1]
    end

    def show_info
      puts @first_name + ' ' + @last_name
    end
  end

bad

  class TheTest
    def initialize(*args)
      @first_name = args[0]
      @last_name = args[1]
    end



    def show_info
      puts @first_name + ' ' + @last_name
    end
  end

Development

  • Clone the project
https://github.com/jstloyal/Ruby_Capstone.git
  • Run the Application

Bad Code

Microverse Logo

Good Code

Microverse Logo

Built With

This project was built using these technologies.

  • Ruby
  • Rubocop
  • VsCode
  • RSpec
  • Git-Flow

Live version

You can see it working Run on Repl.it

You can watch how to use the linter here: [drive.google.com]

Contributor

👤 Author

​## Adetayo Sunkanmi

Acknowledgements

License

📝 This project is MIT licensed.

About

A linter developed in Ruby which detects some errors within ruby code. This is a beginner linter template which can be further improved.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages