Code Monkey home page Code Monkey logo

code_counter's Introduction

code_counter

Code Climate Coverage Gitter Chat

This started as an extraction of the Rails rake stat task, so it could be used on non-Rails projects and have it's features slowly expanded.

Improvements include:

  • Support for RSpec and Cucumber out of the box.
  • Includes .rake files.
  • Includes scripts (by default, in bin/, script/, and scripts/) with no extension, provided they have a shebang line.

Requirements

This project requires Ruby 1.9.x or higher.

Usage

Rake

Add this to the bottom of your Rakefile:

require 'code_counter'

Then, when you run rake -T you'll see a stats task, unless you already had one defined. If you have an existing task named stats, and want to use this one, simply make a task of a new name that depends on the code_counter task, like so:

task :new_stats => :code_counter

To configure the task:

task :stats_configuration do
  CodeCounter::Engine.clear!
  CodeCounter::Engine.init!

  # By default, this will recursively add the specified path, and only look for
  # files ending in `.rb`, `.rake`, or `.feature`.
  CodeCounter::Engine.add_path("Some Group", "some/path")

  # Don't add recursively:
  CodeCounter::Engine.add_path("Some Group", "other/path", false)

  # Add recursively, and don't filter by file extension:
  CodeCounter::Engine.add_path("Some Group", "my/script/dir", true, true)
end

# Add a dependency on our config task here so that our config gets loaded when
# we run `rake stats`.
task :code_counter => :stats_configuration

CLI

code_counter

Additionally, you can configure things using some environment variables:

  • ADDITIONAL_SOURCE_DIRECTORIES: A comma-separated list of directories to scan for source files. You may assign a directory to a named group by prefixing the path with a group name and colon. E.G. ADDITIONAL_SOURCE_DIRECTORIES='Libraries:my_awesome_code'
  • ADDITIONAL_SCRIPT_DIRECTORIES: A comma-separated list of directories to scan for scripts. You may assign a directory to a named group by prefixing the path with a group name and colon. E.G. ADDITIONAL_SCRIPT_DIRECTORIES='Scripts:my_awesome_scripts'
  • IGNORE_FILE_GLOBS: A comma-separated list of file globs to ignore.

TODOs

  • make bin accept passed cmd line arguments to run
  • stop relying on ENV vars
  • count number of total files
  • count number of of .rb or passed in filter files
  • find todo, perf, bug, hack, etc comments and display them with info about them (line number etc)
  • reduce duplication between bin and task
  • comments:code ratio
  • support for more languages
    • JS
    • CoffeeScript
    • Gherkin
  • don't accidentally count actual binaries
  • Include Rakefile* in analysis

[email protected]

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Distributed under the MIT license. See LICENSE.md for details, including authorship/ownership.

code_counter's People

Contributors

danmayer avatar mrjoy avatar

Watchers

 avatar  avatar

Forkers

vjt

code_counter'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.