Skip to content

A tool that will scan your code written in Ruby (.rb files) with a set of style rules and will report any errors to you that it finds.

Notifications You must be signed in to change notification settings

EricMbouwe/Ruby-Linter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hire-badge Twitter Follow

Ruby Linter

This is a linter developed in Ruby for Ruby (.rb) files. It's a linter for beginners, it provides feedback about errors or warning in code line by line by :

  • flagging bugs in your code from some syntax errors
  • giving you warnings when code is not correct
  • heplping you to keep a consistent code style

screenshot

Presentation video

Examples

Limit lines to 50 characters.

# bad
puts 'lorem pesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets Lorem Ipsum passages, and more recently with desktop publishing'

# good
puts 'lorem pesetting, remaining essentially unchanged. It was '
puts 'popularised in the 1960s with the release of Letraset sheets'
puts 'Lorem Ipsum passages, and more recently with desktop publishing'

Avoid single-line methods.

# bad
def too_much; something; something_else; end

# okish - notice that the first ; is required
def no_braces_method; body end

# okish - notice that the second ; is optional
def no_braces_method; body; end

# okish - valid syntax, but no ; makes it kind of hard to read
def some_method() body end

# good
def some_method
  body
end

No spaces after (, [ or before ], ). Use spaces around { and before }.

# bad
some( arg ).other
[ 1, 2, 3 ].each{|e| puts e}

# good
some(arg).other
[1, 2, 3].each { |e| puts e }

Use spaces around { and before }.

# bad
hash = {tom:12, max:15}

# good
hash = { tom:12, max:15 }

Use CamelCase for classes and modules.

# bad
class Someclass
  # some code
end

class Some_Class
  # some code
end

class SomeXml
  # some code
end

class XmlSomething
  # some code
end

# good
class SomeClass
  # some code
end

class SomeXML
  # some code
end

class XMLSomething
  # some code
end

Use spaces around operators, after commas, colons and semicolons.

# bad
sum=1+2
a,b=1,2

# good
sum = 1 + 2
a, b = 1, 2

Built With

  • Ruby
  • Visual Studio Code
  • rspec
  • Rubocop
  • colorize

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This project runs on Ruby

After installation, run ruby -v to make sure Ruby installed correctly. Example

$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin17]

How it works?

The linter parse your file line by line from the first one to the last and flag errors and/or warnings on your terminal

Installing

  • In your terminal, Clone the project locally and then Change directory to the root of the project
$ git clone https://github.com/EricMbouwe/Ruby-capstone-project.git

$ cd Ruby-capstone-project

How to use?

  • After installing the project, copy and paste your target file "filename.rb" to the project's /lints folder

  • In your terminal, install the gems in the Gemfile by running

bundle install

Else you can install the gems system-wide by using:

gem install rspec
gem install colorize

Run

  • In your Terminal run
$ bin/main.rb lints/filename.rb

Author

👤 Eric Mbouwe

🤝 Contributing

Contributions, issues and feature requests are welcome! Start by:

  • Forking the project
  • Cloning the project to your local machine
  • cd into the project directory
  • Run git checkout -b your-branch-name
  • Make your contributions
  • Push your branch up to your forked repository
  • Open a Pull Request with a detailed description to the development branch of the original project for a review
Please feel free to contribute to any of these!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

A tool that will scan your code written in Ruby (.rb files) with a set of style rules and will report any errors to you that it finds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages