question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow immutable state variables to be named in CAPS_SNAKE_CASE

See original GitHub issue

This is more of a question than a bug report – IMO immutable variables should be allowed to be treated as constants, since they in fact cannot be changed.

Currently the code below returns a warning Variable name must be in mixedCase when linted with the recommended ruleset.

contract Test {
  uint16 public immutable TEST_MODE;
  constructor(uint16 _testMode) { TEST_MODE = _testMode; }
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
benesjancommented, May 30, 2022

I don’t know what is the state of this issue now but having support for this would be great 👍

5reactions
quezakcommented, Aug 5, 2020

It’s hard to think of a good single setting here, since it really concerns two rules. The simplest way would be to have some “general config” option treat-immutable-vars-as-constants, but that’s kinda bad design since it’s not really a general option, just a two-rule option… Maybe it will be enough to add a treat-immutable-var-as-constant: true option to both these rules? You’d have to turn on both to have immutable variables linted in CAPS_SNAKE_CASE, and without them it would lint them in mixedCase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solidity 0.6.x features: Saving Storage Costs with Immutables
Immutable state variables can only be assigned during contract creation, but will remain constant throughout the life-time of a deployed ...
Read more >
state variable - What is the immutable keyword in Solidity?
State variables can be marked immutable which causes them to be read-only, but assignable in the constructor. The value will be stored ...
Read more >
Solidity: AppStorage for distinguishing state variables and ...
AppStorage is a variable naming technique which makes state variables clear in your code and prevents name clashes with other kinds of variables...
Read more >
Mutable and Immutable Objects - Manning
An object created and given a value is assigned some space in memory. The variable name bound to the object points to that...
Read more >
Reading 9: Mutability & Immutability
Since String is immutable, once created, a String object always has the same ... variables named list (an instance variable and a constructor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found