Git Product home page Git Product logo

fixme's Introduction

fixme

FIXME comments that raise after a certain point in time:

FIXME "2014-07-31: Stop hard-coding currency."
currency = "USD"

This library makes a FIXME() method available everywhere.

Starting July 31st 2014, the "FIXME" line in the example above would raise Fixme::UnfixedError with the message "Fix by 2014-07-31: Stop hard-coding currency."

You may want to use these bad boys next to:

  • Temporary quick fixes, to ensure they really are temporary.
  • Code that supports legacy workflows during a transitional period.
  • Experiments, to remember to evaluate them and make a decision.
  • Anything else you can't do now but should fix later.

For simplicity, the date comparison uses machine-local time (not e.g. the Rails configured time zone).

Environment awareness

If Rails.env (Ruby on Rails), ENV["APP_ENV"] or ENV["RACK_ENV"] (e.g. Sinatra) is present, it will only ever raise in the "test" and "development" environments. That is, the production app will never raise these exceptions.

Do something other than raise

When these exceptions trigger on your CI server they stop the line, blocking your delivery chain until they're addressed. This could be what you want, or it could be a little annoying.

So you can configure the library to do something other than raise:

# In a Rails project, this might be in config/initializers/fixme.rb
Fixme.explode_with do |details|
  YourOwnCodeOrSomeLibrary.email_developers(details.full_message)
  YourOwnCodeOrSomeLibrary.notify_chat(details.full_message)
end

There's also details.date, details.due_days_ago, details.message and details.backtrace.

You can call Fixme.raise_from(details) to get the default behavior, if you want that under certain conditions:

Fixme.explode_with do |details|
  if details.due_days_ago > 5
    Fixme.raise_from(details)
  else
    YourOwnCodeOrSomeLibrary.notify_chat(details.full_message)
  end
end

Selectively disable

If you e.g. don't want your CI server to raise, make it set the environment variable DISABLE_FIXME_LIB.

Pro-tips

  • Make sure it's clear from the exception or from a separate comment just what should be done โ€“ sometimes not even the person who wrote the FIXME will remember what you're meant to change.
  • If a FIXME raises right in a class/module, rather than inside a method, there may be follow-on errors (about missing methods and such) since the rest of that file won't execute. Being aware of this can help understand otherwise confusing CI failures.

Installation

Add this line to your application's Gemfile:

gem 'fixme'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fixme

Develop

Clone the repo, then:

bundle  # Install gem dependencies.
rake    # Run tests.

Also see

Contributors

License

Copyright (c) 2014 Henrik Nyh

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fixme's People

Contributors

dependabot[bot] avatar henrik avatar markogresak avatar olleolleolle avatar

Stargazers

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

Watchers

 avatar  avatar

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