fixme 4.1.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/CHANGELOG.md +13 -0
- data/README.md +9 -6
- data/fixme.gemspec +2 -1
- data/lib/fixme/version.rb +1 -1
- data/lib/fixme.rb +9 -4
- data/spec/fixme_spec.rb +43 -4
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16e16af88b6b78de4b441bad22260a6ebadc1bc2daaeff1a1244c43b715da874
|
4
|
+
data.tar.gz: cdfc448199b5ddeb1ae6f7efd6fb801002b40f994dc78fc63309183f6f347c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 320d27cacd701df672ec5fb7dcbcb31feb9017fd4e06d294828a94bc4775a566be772806076f5d4c96f2cd23a05092d763648f23179957dd8305c2a25e5b5f3e
|
7
|
+
data.tar.gz: 91ed853d3d34ea23789c2f042c1db46c430303fa4ea07b55fae8e25d9602478a40eba6624b8d3a827c99e7c758fd2d045e75d1c452c81433842a6f4ff19b4e90
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ["3.0", "2.7", "2.6"]
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
+
uses: ruby/setup-ruby@ae9cb3b565e36682a2c6045e4f664388da4c73aa
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 6.1.0
|
4
|
+
|
5
|
+
* Checks `APP_ENV`, not just `RACK_ENV`, as this is [what Sinatra now encourages using](https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md#200--2017-04-10).
|
6
|
+
|
7
|
+
## 6.0.0
|
8
|
+
|
9
|
+
* Require zero-padded month and day, i.e. disallow `2019-1-2`. This enforced consistency makes it easier to grep for an exploded FIXME.
|
10
|
+
|
11
|
+
## 5.0.0 and earlier
|
12
|
+
|
13
|
+
* Please see commit history, or make a pull request to update this file.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
FIXME comments that raise after a certain point in time:
|
4
4
|
|
5
|
-
```
|
5
|
+
```ruby
|
6
6
|
FIXME "2014-07-31: Stop hard-coding currency."
|
7
7
|
currency = "USD"
|
8
8
|
```
|
@@ -20,11 +20,9 @@ You may want to use these bad boys next to:
|
|
20
20
|
|
21
21
|
For simplicity, the date comparison uses machine-local time (not e.g. the Rails configured time zone).
|
22
22
|
|
23
|
-
Protip: 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 quickfix will remember what you're meant to change.
|
24
|
-
|
25
23
|
### Environment awareness
|
26
24
|
|
27
|
-
If `Rails.env` (Ruby on Rails) 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.
|
25
|
+
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.
|
28
26
|
|
29
27
|
### Do something other than raise
|
30
28
|
|
@@ -32,7 +30,7 @@ When these exceptions trigger on your CI server they stop the line, blocking you
|
|
32
30
|
|
33
31
|
So you can configure the library to do something other than raise:
|
34
32
|
|
35
|
-
```
|
33
|
+
```ruby
|
36
34
|
# In a Rails project, this might be in config/initializers/fixme.rb
|
37
35
|
Fixme.explode_with do |details|
|
38
36
|
YourOwnCodeOrSomeLibrary.email_developers(details.full_message)
|
@@ -44,7 +42,7 @@ There's also `details.date`, `details.due_days_ago`, `details.message` and `deta
|
|
44
42
|
|
45
43
|
You can call `Fixme.raise_from(details)` to get the default behavior, if you want that under certain conditions:
|
46
44
|
|
47
|
-
```
|
45
|
+
```ruby
|
48
46
|
Fixme.explode_with do |details|
|
49
47
|
if details.due_days_ago > 5
|
50
48
|
Fixme.raise_from(details)
|
@@ -58,6 +56,11 @@ end
|
|
58
56
|
|
59
57
|
If you e.g. don't want your CI server to raise, make it set the environment variable `DISABLE_FIXME_LIB`.
|
60
58
|
|
59
|
+
### Pro-tips
|
60
|
+
|
61
|
+
* 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.
|
62
|
+
* 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.
|
63
|
+
|
61
64
|
|
62
65
|
## Installation
|
63
66
|
|
data/fixme.gemspec
CHANGED
@@ -11,13 +11,14 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{Comments that raise after a certain point in time.}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
14
|
+
spec.metadata = { "rubygems_mfa_required" => "true" }
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0")
|
16
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
19
|
spec.require_paths = ["lib"]
|
19
20
|
|
20
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
21
22
|
spec.add_development_dependency "rake"
|
22
23
|
spec.add_development_dependency "rspec"
|
23
24
|
spec.add_development_dependency "timecop"
|
data/lib/fixme/version.rb
CHANGED
data/lib/fixme.rb
CHANGED
@@ -2,7 +2,8 @@ require "fixme/version"
|
|
2
2
|
require "date"
|
3
3
|
|
4
4
|
module Fixme
|
5
|
-
|
5
|
+
# We intentionally do NOT inherit from StandardError, because we don't want these errors caught by a blanket "rescue".
|
6
|
+
UnfixedError = Class.new(Exception)
|
6
7
|
|
7
8
|
Details = Struct.new(:full_message, :backtrace, :date, :message) do
|
8
9
|
def due_days_ago
|
@@ -63,7 +64,11 @@ module Fixme
|
|
63
64
|
private
|
64
65
|
|
65
66
|
def framework_env
|
66
|
-
defined?(Rails)
|
67
|
+
if defined?(Rails)
|
68
|
+
Rails.env
|
69
|
+
else
|
70
|
+
ENV["RACK_ENV"] || ENV["APP_ENV"]
|
71
|
+
end
|
67
72
|
end
|
68
73
|
|
69
74
|
def disallow_timecop(&block)
|
@@ -75,10 +80,10 @@ module Fixme
|
|
75
80
|
end
|
76
81
|
|
77
82
|
def parse
|
78
|
-
match = @date_and_message.match(/\A(\d\d\d\d-\d\d
|
83
|
+
match = @date_and_message.match(/\A(\d\d\d\d-\d\d-\d\d): (.+)\z/)
|
79
84
|
|
80
85
|
unless match
|
81
|
-
raise %{FIXME does not follow the "2015-01-
|
86
|
+
raise %{FIXME does not follow the "2015-01-31: Foo" format: #{@date_and_message.inspect}}
|
82
87
|
end
|
83
88
|
|
84
89
|
raw_date, message = match.captures
|
data/spec/fixme_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Fixme, "#FIXME" do
|
|
29
29
|
it "truncates the backtrace to exclude the library itself" do
|
30
30
|
begin
|
31
31
|
FIXME "2013-12-31: Remove this stuff."
|
32
|
-
rescue => e
|
32
|
+
rescue Fixme::UnfixedError => e
|
33
33
|
expect(e.backtrace.first).to include("fixme_spec.rb:")
|
34
34
|
end
|
35
35
|
end
|
@@ -41,10 +41,16 @@ describe Fixme, "#FIXME" do
|
|
41
41
|
}.to raise_error("Fix by 2013-12-31: Remove this: and this.")
|
42
42
|
end
|
43
43
|
|
44
|
-
it "complains if the desired format is not adhered to" do
|
44
|
+
it "complains if the desired message format is not adhered to" do
|
45
45
|
expect {
|
46
46
|
FIXME "9999-01-01, Learn to: type"
|
47
|
-
}.to raise_error(%{FIXME does not follow the "2015-01-
|
47
|
+
}.to raise_error(%{FIXME does not follow the "2015-01-31: Foo" format: "9999-01-01, Learn to: type"})
|
48
|
+
end
|
49
|
+
|
50
|
+
it "complains if the extended ISO 8601 date format is not adhered to" do
|
51
|
+
expect {
|
52
|
+
FIXME "9999-01-1: Foo"
|
53
|
+
}.to raise_error(%{FIXME does not follow the "2015-01-31: Foo" format: "9999-01-1: Foo"})
|
48
54
|
end
|
49
55
|
|
50
56
|
it "is available everywhere" do
|
@@ -55,6 +61,15 @@ describe Fixme, "#FIXME" do
|
|
55
61
|
}.to raise_error(Fixme::UnfixedError)
|
56
62
|
end
|
57
63
|
|
64
|
+
it "is not caught by a blanket 'rescue'" do
|
65
|
+
expect {
|
66
|
+
begin
|
67
|
+
FIXME "2000-01-01: Don't be caught."
|
68
|
+
rescue
|
69
|
+
end
|
70
|
+
}.to raise_error(Fixme::UnfixedError)
|
71
|
+
end
|
72
|
+
|
58
73
|
it "is not fooled by the Timecop gem" do
|
59
74
|
future_date = Date.today + 2
|
60
75
|
|
@@ -86,7 +101,31 @@ describe Fixme, "#FIXME" do
|
|
86
101
|
end
|
87
102
|
end
|
88
103
|
|
89
|
-
context "when
|
104
|
+
context "when an APP_ENV is detected" do
|
105
|
+
before do
|
106
|
+
stub_env "DISABLE_FIXME_LIB", nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "raises in the 'test' environment" do
|
110
|
+
stub_env "RACK_ENV", nil
|
111
|
+
stub_env "APP_ENV", "test"
|
112
|
+
expect_to_raise
|
113
|
+
end
|
114
|
+
|
115
|
+
it "raises in the 'development' environment" do
|
116
|
+
stub_env "RACK_ENV", nil
|
117
|
+
stub_env "APP_ENV", "development"
|
118
|
+
expect_to_raise
|
119
|
+
end
|
120
|
+
|
121
|
+
it "does not raise in other environments" do
|
122
|
+
stub_env "RACK_ENV", nil
|
123
|
+
stub_env "APP_ENV", "production"
|
124
|
+
expect_not_to_raise
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when a RACK_ENV is detected" do
|
90
129
|
before do
|
91
130
|
stub_env "DISABLE_FIXME_LIB", nil
|
92
131
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/workflows/ci.yml"
|
76
77
|
- ".gitignore"
|
78
|
+
- CHANGELOG.md
|
77
79
|
- Gemfile
|
78
80
|
- README.md
|
79
81
|
- Rakefile
|
@@ -84,7 +86,8 @@ files:
|
|
84
86
|
homepage: ''
|
85
87
|
licenses:
|
86
88
|
- MIT
|
87
|
-
metadata:
|
89
|
+
metadata:
|
90
|
+
rubygems_mfa_required: 'true'
|
88
91
|
post_install_message:
|
89
92
|
rdoc_options: []
|
90
93
|
require_paths:
|
@@ -100,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
103
|
- !ruby/object:Gem::Version
|
101
104
|
version: '0'
|
102
105
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.2.2
|
106
|
+
rubygems_version: 3.2.31
|
105
107
|
signing_key:
|
106
108
|
specification_version: 4
|
107
109
|
summary: Comments that raise after a certain point in time.
|