Code Monkey home page Code Monkey logo

ruby-capstone-project's Introduction

Ruby Capstone Project - Ruby Linter

View Code Github Issues GitHub Pull Requests

About

The whole idea of writing code to check another code is intriguing at the same time cognitively demanding. Building Linters for Ruby, the project provides feedback about errors or warnings in code little by little. The project was built completely with Ruby following all possible best practices. Rubocop was used as a code-linter alongside Gitflow to ensure I maintain good coding standards.

The Build

The custom Ruby linter currently checks/detects for the following errors/warnings.

  • check for wrong indentation
  • check for trailing spaces
  • check for missing/unexpected tags i.e. '( )', '[ ]', and '{ }'
  • check missing/unexpected end
  • check empty line error

Below are demonstrations of good and bad code for the above cases. I will use the pipe '|' symbol to indicate cursor position where necessary.

Indentation Error Check

# Good Code

class Game
  def initialize(player1, player2)
    @player1 = player1] 
    @player2 = player2
  end

end

# Bad Code

class Game
  def initialize(player1, player2)
    @player1 = player1] 
     @player2 = player2
  end

end

Trailing spaces

note where the cursor(!) is on the bad code

# Good Code

class Game
  def initialize(player1, player2)
    @player1 = player1
    @player2 = player2
  end
end

# Bad Code

class Game
  def initialize(player1, player2) !
    @player1 = player1
     @player2 = player2
  end

end

Missing/Unexpected Tag

# Good Code


class Game
  def initialize(player1, player2)
    @player1 = player1
    @player2 = player2
  end
end

# Bad Code

class Game
  def initialize(player1, player2)
    @player1 = player1
    @player2 = ([player2]
  end
end

Missing/unexpected end

# Good Code

class Game
  def initialize(player1, player2)
    @player1 = player1
    @player2 = player2
  end
end

# Bad Code

class Game
  def initialize(player1, player2)
    @player1 = player1 
    @player2 = player2
  end
end
end

Empty line error

# Good Code

class Game
  def initialize(player1, player2)
    @player1 = player1
    @player2 = player2
  end
end

# Bad Code

class Game
  def initialize(player1, player2)
    @player1 = player1

     @player2 = player2
  end
end

Built With

  • Ruby
  • RSpec for Ruby Testing

Getting Started

To get a local copy of the repository please run the following commands on your terminal:

$ cd <folder>
$ git clone https://github.com/taiwo2/Ruby-Capstone-Project.git

To check for errors on a file:

$ bin/main.rb

Testing

To test the code, run rspec from root of the folder using terminal. Note: sample.rb has been excluded from rubocop checks to allow RSpec testing without interfering with Gitflow actions

Rspec is used for the test, to install the gem file, run

$ bundle install 

But before that, 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 
$ gem install colorize 

Author

๐Ÿ‘ค Taiwo Adetona

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!

Show your support

Give a โญ๏ธ if you like this project!

Acknowledgments

ruby-capstone-project's People

Contributors

taiwo2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.