Add new cop Lint/OrAssignmentToConstant#9363
Merged
dvandersluis merged 1 commit intorubocop:masterfrom Jan 15, 2021
Merged
Conversation
89e3ad8 to
18089b8
Compare
Member
dvandersluis
left a comment
There was a problem hiding this comment.
Looks like a useful cop!
ad16e68 to
6d8fc1a
Compare
Contributor
Author
|
Thank you for review. |
This cop checks for unintended or-assignment to a constant. Constants should always be assigned in the same location. And its value should always be the same. If constants are assigned in multiple locations, the result may vary depending on the order of `require`. Also, if you already have such an implementation, auto-correction may change the result. ```ruby CONST ||= 1 CONST = 1 ```
c31fdf9 to
93a7e0d
Compare
dvandersluis
approved these changes
Jan 14, 2021
Member
dvandersluis
left a comment
There was a problem hiding this comment.
LGTM, thanks 👍
@rubocop-hq/rubocop-core ci/circleci: cc-upload-coverage keeps failing on this PR, anyone have any ideas why?
Member
It's possible that Code Climate's API wasn't working properly. I think this failure can be ignored. #!/bin/bash -eo pipefail
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json --parts 6 --output tmp/codeclimate.total.json
./tmp/cc-test-reporter upload-coverage --input tmp/codeclimate.total.json
Error: response from https://api.codeclimate.com/v1/test_reports.
HTTP 401: You are not authorized for this action
Usage:
cc-test-reporter upload-coverage [flags]
Flags:
-s, --batch-size int batch size for source files (default 500)
-e, --endpoint string endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
-r, --id string reporter identifier (default "a11b66bfbb1acdf220d5cb317b2e945a986fd85adebe29a76d411ad6d74ec31f")
-i, --input string input path (default "coverage/codeclimate.json")
--insecure send coverage insecurely (without HTTPS)
Global Flags:
-d, --debug run in debug mode
Exited with code exit status 255
CircleCI received exit code 255 |
Member
|
@koic yeah that’s what I figured but I wanted to double check, thanks. |
jmkoni
pushed a commit
to standardrb/standard
that referenced
this pull request
May 3, 2021
* Update rubocop from 1.12.1 to [1.13.0](https://github.com/rubocop-hq/rubocop/releases/tag/v1.13.0) * Update rubocop-performance from 1.9.2 to [1.11.1](https://github.com/rubocop-hq/rubocop-performance/releases/tag/v1.11.1) * Enabled the following rules: * [`Performance/RedundantSplitRegexpArgument`](rubocop/rubocop-performance#190) * [`Style/IfWithBooleanLiteralBranches`](rubocop/rubocop#9396) * [`Lint/TripleQuotes`](rubocop/rubocop#9402) * [`Lint/SymbolConversion`](rubocop/rubocop#9362) * [`Lint/OrAssignmentToConstant`](rubocop/rubocop#9363) * [`Lint/NumberedParameterAssignment`](rubocop/rubocop#9326) * [`Style/HashConversion`](rubocop/rubocop#9478) * [`Gemspec/DateAssignment`](rubocop/rubocop#9496) * [`Style/StringChars`](rubocop/rubocop#9615)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This cop checks unintended or-assignment to constant.
Usually, you don't need to consider whether A is already assigned elsewhere.
Before submitting the PR make sure the following are checked:
Commit message starts with[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.