Git Product home page Git Product logo

my_ruby_linter's Introduction

Ruby linter

Ruby capstone project

Description

The aim of this project is to create my own linter file which is gonna detect errors inside the user's code and display messages with detail about the error, it checks:

  • Indentation : A correct indentation is supposed to be 2 lines.
  • Missing parenthesis/brackets/curly brackets : To prevent bugs.
  • Lines with trailing spaces.
  • Multiple empty lines.
  • A missing empty line at the end of the file
  • Unclosed block.

The linter returns errors and warning depending to the level of the issue in this format

screenshot

Project Structure

This project includes the following files:

├──.github
├── gitflows
    ├── linters.yml
    ├── tests.yml
├── bin
│   ├── main.rb
└── lib
│   ├── modules
│   │   ├── checker_module.rb
│   │   ├── file_reader.rb
│   ├── checker.rb
│   └── error_handler.rb
├── images
├── ├── capst.PNG
├── spec
│   ├── checker_spec.rb
│   ├── file_reader_spec.rb
│   ├── checker_module_spec.rb
│   ├── error_handler_spec.rb
│   ├── spec_helper.rb
├── .gitignore
├── .rspec
├── test_correct.rb
├── test_bug.rb
├── bad_extension.txt
├── README.md

Rules

Here are some examples of bad / good code to be checked

Indentation. (indentation set to 2)

Bad code:

def something
return true if something_else
end

Good code:

def something
  return true if something_else
end

Missing Parenthesis/Brackets/Curly Brackets

Bad code:

(x + y) * (z - w

Good code:

(x + y) * (z - w)

Lines with trailing spaces

The | symbol shows where the line ends

Bad code:

if bad?     |

Good code:

if !bad?|

Multiple empty lines

Bad code:

end


if something...

Good code:

end

if something...

A missing empty line at the end of the file

Bad code:

end

Good code:

end

Unclosed block

Bad code:

def
  some awesome code


if something ...

Good code:

def
  some awesome code
end

if something

GET STARTED

Prerequisits

  • Install at least one code editor
  • Install Ruby to execute the project
  • [optional]:Install Rspec

clone the repository

  • Run $ git clone https://github.com/pacyL2K19/my_ruby_linter.git
  • go to the project directory $ cd my_ruby_linter
  • Run the command $ ruby bin/main.rb

The last command will ask you to put file path to the file you want to check

Put :

  • test_correct.rb : To check the sample file provided which doesn't contain any error or warning
  • test_bug.rb : To check a wrong sample file which contains errors and warnings
  • bad_extension.txt : To check a no-Ruby file and see error message
  • something_bad.random : To check the unexistant file

Original project idea and specifications

Please click here to see the project specifics.

Author

👤 Pacifique Linjanja

🤝 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 MIT licensed.

my_ruby_linter's People

Contributors

pacyl2k19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

my_ruby_linter's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.