Coder Social home page Coder Social logo

dnnx / sandi_meter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makaroni4/sandi_meter

0.0 1.0 0.0 206 KB

Static analysis tool for checking Ruby code for Sandi Metz' rules.

Home Page: https://rubygems.org/gems/sandi_meter

License: MIT License

Ruby 74.91% CSS 20.13% JavaScript 4.96%

sandi_meter's Introduction

SandiMeter

Build Status Gem Version

Static analysis tool for checking your Ruby code for Sandi Metz' four rules.

  • 100 lines per class
  • 5 lines per method
  • 4 params per method call (and don't even try cheating with hash params)
  • 1 instance variables per controller' action

CLI mode

gem install sandi_meter

sandi_meter --help
-g, --graph                      Create folder and log data to graph
-l, --log                        Show syntax error and indentation log output
-p, --path PATH                  Path to folder or file to analyze
-r, --rules                      Show rules
-h, --help                       Help

sandi_meter -p ~/your/ruby/or/rails/project

1. 94% of classes are under 100 lines.
2. 53% of methods are under 5 lines.
3. 98% of methods calls accepts are less than 4 parameters.
4. 21% of controllers have one instance variable per action.

HTML mode

Try using gem with -g (--graph) option, so it will create a folder with beautiful html output and log file with results of any scan.

SandiMeter HTML mode

Ruby script mode

require 'sandi_meter/file_scanner'
require 'pp'

scanner = SandiMeter::FileScanner.new
data = scanner.scan(PATH_TO_PROJECT)
pp data
# {:first_rule=>
#   {:small_classes_amount=>916,
#    :total_classes_amount=>937,
#    :misindented_classes_amount=>1},
#  :second_rule=>
#   {:small_methods_amount=>1144,
#    :total_methods_amount=>1833,
#    :misindented_methods_amount=>0},
#  :third_rule=>{:proper_method_calls=>5857, :total_method_calls=>5894},
#  :fourth_rule=>{:proper_controllers_amount=>17, :total_controllers_amount=>94}}

sandi_meter's People

Contributors

kirs avatar makaroni4 avatar pfhawkins avatar releu avatar

Watchers

 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.