Skip to content

This is a code linter like Rubocop that trawls through your code files and finds problems, such as methods with too many lines, code style violations, or common gotchas.

Georjane/Ruby-Linters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My-Ruby-Linters

Status Github Issues GitHub2 Pull Requests License

Made By Twitter Follow

RuboCop Logo


📝 Content

About   |    Built with   |    Installing   |    Style Guide   |    Author

🧐 About

This is a code linter like Rubocop that trawls through your code files and finds problems, such as methods with too many lines, code style violations, or common gotchas.


🔧 Built with

  • Ruby
  • RSpec for Ruby Testing

🛠 Installing

Pre-requisites

  • Ruby installed on local machine. Please go to this link if you need to install it.

Usage

Clone this repository on the command promp or console using

git clone https://github.com/Georjane/Ruby-Linters.git
cd Ruby-Linters

Type in the following command to run the linter on a test file

ruby bin/main.rb

Testing

Test class methods using RSpec by running the command in the root directory

rspec

But before testing using RSpec you can install the gem file by running the command

$ bundle install 

Also make sure you have bundler installed on your system, else run

$ gem install bundler 

or you simply install the the following directly using

$ gem install rspec 

Style Guide

1. Department Naming

Naming cops check for naming issue of your code, such as method name, constant name, file name, etc.

- Naming/VariableName

This cop makes sure that all variables use the configured style, snake_case for their names.

# bad
myVar = 5

# good
my_var = 5

- Naming/MethodName

This cop makes sure that all methods use the configured style, snake_case for their names.

# bad
def MyMethodName
  # code
end

# good
def my_method_name
  # code
end

- Naming/ClassAndModuleCamelCase

This cop checks for class and module names with an underscore in them.

# bad
class My_Class
end
module My_Module
end

# good
class MyClass
end
module MyModule
end

2. Department Metrics

Metrics cops deal with properties of the source code that can be measured, such as class length, method length, etc. Generally speaking, they have a configuration parameter called Max and when running rubocop --auto-gen-config, this parameter will be set to the highest value found for the inspected code. In this linter, Max value has being set to 10.

- Metrics/BlockLength

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored.

3. Department Layout

Layout cops inspect your code for consistent use of indentation, alignment, and white space.

- Layout/EmptyLines

This cop checks for two or more consecutive blank lines.

# bad - It has two empty lines.
my_method


my_method

# good
my_method

my_method

✒️ Author

👤 Witah Georjane

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

👍 Show your support

Give a ⭐️ if you like this project!

📝 License

This project is free to use as learning purposes. For any external content (e.g. logo, images, ...), please contact the proper author and check their license of use.

About

This is a code linter like Rubocop that trawls through your code files and finds problems, such as methods with too many lines, code style violations, or common gotchas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages