| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).
Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).
That cop and enforced style will reduce the our code review cost.
|
|
|
|
|
|
|
|
|
|
| |
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).
I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
|
|
|
|
|
| |
Check that options passed to the to_json are passed to all objects that
respond to as_json.
|
|
|
|
|
|
|
|
| |
Ruby 2.4 has native `Regexp#match?`.
https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match-3F
Related #32034.
|
|
|
|
| |
Follow up of #31390.
|
|
|
|
|
|
|
| |
The def with blank `()` was newly added in #31176, but we have not used
the blank `()` style in most part of our code base.
So I've enabled `Style/DefWithParentheses` to prevent to newly added the
code.
|
| |
|
|
|
|
| |
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
|
| |
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Using the method you're testing to generate expected
values can lead to bugs being masked.
|
|
|
|
|
|
|
|
|
|
|
| |
- When `as_json` returns `Infinity` or `NaN` as the value of any of the key,
we don't used to call `as_json` on it as it was treated as primitive.
- This used to pass `Infinity` or `NaN` to `JSON.generate` and Ruby used
to throw an error for `Infinity/NaN not allowed in JSON.`
- This patch changes the code to call `as_json` on these primitives so
that they are converted to proper values before being passed to
`JSON.generate`.
- Fixes #26877.
|
| |
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
| |
Where appropriate prefer the more concise Regexp#match?, String#include?,
String#start_with?, and String#end_with?
|
| |
|
| |
|
|
|
|
| |
Fixes CVE-2015-3226
|
| |
|
|
|
|
| |
onwards.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
It’s used at so many places that extracting it out into a helper file
is worth doing.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Also added the missing CHANGELOG entry for #12183 @ 80e7552073 and
4d02296cfb.
|
| |
|
|
|
|
|
|
|
|
|
| |
Got all the tests passing again.
Support for `encode_json` has been removed (and consequently the
ability to encode `BigDecimal`s as numbers, as mentioned in the
previous commit). Install the `activesupport-json_encoder` gem
to get it back.
|
|
|
|
|
|
|
|
|
|
| |
This is because the new encoder will no longer support encode_json.
Therefore our only choice is to return `to_i` or `to_s` in
`BigDecimal#as_json`. Since casting a BigDecimal to an integer is
most likely a lossy operation, we chose to encode it as a string.
Support for encoding BigDecimal as a string will return via the
`activesupport-json_encoder` gem.
|
| |
|
|
|
|
| |
correctly
|
|
|
|
|
| |
should also call #as_json on the children without options (instead of
nil)
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, calling `::JSON.{generate,dump}` sometimes causes
unexpected failures such as intridea/multi_json#86.
`::JSON.{generate,dump}` now bypasses the ActiveSupport JSON encoder
completely and yields the same result with or without ActiveSupport.
This means that it will **not** call `as_json` and will ignore any
options that the JSON gem does not natively understand. To invoke
ActiveSupport's JSON encoder instead, use `obj.to_json(options)` or
`ActiveSupport::JSON.encode(obj, options)`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See [1] for why this is not a good idea.
As part of this refactor, circular reference protection in as_json has
been removed and the corresponding error class has been deprecated.
As discussed with @jeremy, circular reference error is considered
programmer errors and protecting against it is out of scope for
the encoder.
This is again based on the excellent work by @sergiocampama in #11728.
[1]: https://github.com/intridea/multi_json/pull/138#issuecomment-24468223
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
JSON.{dump,generate} offered by the JSON gem is not compatiable with
Rails at the moment and can cause a lot of subtle bugs when passed
certain data structures. This changed all direct usage of the JSON gem
in internal Rails code to always go through AS::JSON.{decode,encode}.
We also shouldn't be implementing `to_json` most of the time, and
these occurances are replaced with an equivilent `as_json`
implementation to avoid problems down the road.
See [1] for all the juicy details.
[1]: intridea/multi_json#138 (comment)
|
|
|
|
|
|
|
|
|
|
|
|
| |
These methods now takes the same options as Hash#as_json, for example:
struct = Struct.new(:foo, :bar).new
struct.foo = "hello"
struct.bar = "world"
json = struct.as_json(only: [:foo]) # => {foo: "hello"}
This is extracted from PR #11728 from @sergiocampama, see also the
discussion in #11460.
|