Violations

Parsing

Different error that might happen during file parsing phase.

class ParsingViolation(node=None, text=None)[source]

Bases: dotenv_linter.violations.base.BaseFileViolation

Indicates that given file can not be correctly parsed.

This may include: 1. Incorrect OS behavior 2. Incorrect syntax inside this file 3. Errors in our grammar definition 4. Our internal errors

New in version 0.1.0.

code = 1
error_template = 'Unable to correctly parse dotenv file'

Names

Rules that define how names should be defined.

class SpacedNameViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to use duplicate names variables.

Reasoning:
This spaces will be removed by the parsing mechanism, but they might cause some confusion to users.
Solution:
Remove leading spaces.

Example:

# Correct:
SOME_KEY=1

# Wrong:
    SOME_KEY=1

New in version 0.1.0.

code = 100
error_template = 'Found leading spaces: {0}'
class IncorrectNameViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to use restricted symbols to define names.

Reasoning:
By convention we can only use letters, numbers, and underscores to define dotenv variables. Moreover, variables can not start with numbers.
Solution:
Refactor your file to contain only allowed characters.

Example:

# Correct:
SOME_KEY=1

# Wrong:
SOME-KEY=1

New in version 0.1.0.

code = 101
error_template = 'Found incorrect name: {0}'
class DuplicateNameViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to use duplicate names variables.

Reasoning:
There is no need to crate duplicate variables inside your dotenv file. Since it will be implicitly overridden by the parsing mechanism.
Solution:
Remove one of the duplicate variables.

Example:

# Correct:
SOME_KEY=1
OTHER_KEY=2

# Wrong:
SOME_KEY=1
SOME_KEY=2

New in version 0.1.0.

code = 102
error_template = 'Found duplicate name: {0}'
class RawNameViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to use raw names without equal sign or value.

Reasoning:
It does not make any sense to just state some names. It might also break some .env parsers.
Solution:
Append equal sign to it. So, this would became a declaration of an empty variable. You can also add a value if it makes sense.

Example:

# Correct:
KEY=1
OTHER=

# Wrong:
KEY

New in version 0.1.0.

code = 103
error_template = 'Found raw name without assign: {0}'

Assigns

Rules that define how assigns should be made.

class SpacedAssignViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to write = signs with extra spaces.

Reasoning:
Valid shell syntax requires to write assigns without any spaces.
Solution:
Remove any spaces between the = char.

Example:

# Correct:
KEY=1
OTHER=

# Wrong:
KEY = 1
OTHER =

New in version 0.1.0.

code = 200
error_template = 'Found spaced assign'

Values

Rules about writing correct dotenv values.

By convention we do not print values to the output. Since they might contain private values.

class SpacedValueViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to write values with trailing spaces.

Reasoning:
These spaces are not guaranteed to be preserved. So, it is better not to rely on them.
Solution:
Remove trailing spaces from the value.

New in version 0.1.0.

code = 300
error_template = 'Found spaced value'
class QuotedValueViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to quoted values.

Reasoning:
Dotenv parser usually strips quotes away, so it is hard to say whether these quotes will stay on a final value, or not.
Solution:
Remove any quotes from the value.

Example:

# Correct:
KEY=1

# Wrong:
KEY="1"

New in version 0.1.0.

code = 301
error_template = 'Found quoted value'

Comments

Rules that define how comments should be written.

class SpacedCommentViolation(node, text)[source]

Bases: dotenv_linter.violations.base.BaseFSTViolation

Restricts to write comment with leading or trailing spaces.

Reasoning:
These spaces are meaningless and will be removed. So, why would you want to have them?
Solution:
Remove leading or trailing spaces from the comment body.

New in version 0.1.0.

code = 400
error_template = 'Found spaced comment: {0}'