⚡️Lightning-fast linter for .env files. Written in Rust 🦀

Overview

dotenv-linter

⚡️ Lightning-fast linter for .env files. Written in Rust 🦀

GitHub Actions Coverage Status License Releases

Dotenv-linter can check / fix / compare .env files for problems that may cause the application to malfunction.

Available checks:

     Duplicated Key
     Ending Blank Line
     Extra Blank Line
     Incorrect delimiter
     Key without value
     Leading character
     Lowercase key
     Quote character
     Space character
     Substitution Key
     Trailing whitespace
     Unordered Key

What is a .env file?

     💡  A .env file or dotenv file is a simple text file containing all the environment variables of a project.
    Storing configuration in the environment variables is one of the tenets of the Manifesto of Twelve-Factor App.
    The .env file has a simple key-value format, for example: FOO=BAR.
    More information you can find in articles in English and Russian.

The key features:

     ⚡️  Lightning-fast because it is written in Rust 🦀
     💣  Can be used on any project regardless of the programming language 💥
     🚀  Can be integrated with reviewdog and other CI services (including GitHub Actions and Super-Linter) 🔥

Articles about dotenv-linter:

Dotenv-linter is created & supported by Evrone. What else we develop with Rust.

👨‍💻 Installation

Pre-compiled binary

# Linux / macOS / Windows (MINGW and etc). Installs it into ./bin/ by default
$ curl -sSfL https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s

# Or a shorter way
$ curl -sSfL https://git.io/JLbXn | sh -s

# Specify installation directory and version
$ curl -sSfL https://git.io/JLbXn | sh -s -- -b usr/local/bin v2.0.0

# Alpine Linux (using wget)
$ wget -q -O - https://git.io/JLbXn | sh -s

You can find other installation methods here: https://dotenv-linter.github.io/#/installation

🚀 Usage

Check

By default, dotenv-linter checks all .env files in the current directory:

$ dotenv-linter
Checking .env
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key

Checking .env.test
.env.test:1 LeadingCharacter: Invalid leading character detected

Found 3 problems

🛠 Fix

It can also fix the found warnings with the fix command:

$ dotenv-linter fix
Fixing .env
Original file was backed up to: ".env_1601378896"

.env:2 DuplicatedKey: The BAR key is duplicated
.env:3 LowercaseKey: The foo key should be in uppercase

All warnings are fixed. Total: 2

🤲 Compare

In addition, dotenv-linter can compare .env files with each other and output the difference between them:

$ dotenv-linter compare .env .env.example
Comparing .env
Comparing .env.example
.env is missing keys: BAR
.env.example is missing keys: FOO

Other use cases you can find on the documentation site (https://dotenv-linter.github.io):

🚦 Continuous Integration

dotenv-linter can also be used with CI services such as: GitHub Actions and Circle CI.

🚧 Benchmark

Benchmarking dotenv-linter/dotenv-linter and wemake-services/dotenv-linter has done using the hyperfine utility:

Command Mean [ms] Min [ms] Max [ms] Relative
dotenv-linter/dotenv-linter .env 2.7 ± 0.4 2.0 4.3 1.00
wemake-services/dotenv-linter .env 162.6 ± 12.1 153.0 201.3 60.83 ± 10.20
Content of .env file used for benchmarking
 SPACED=

KEY = VALUE

SECRET="my value"

SECRET=Already defined

kebab-case-name=1
snake_case_name=2

✌️ Mentorship

Dotenv-linter is not just a linter for .env files — it is also a contributor-friendly open-source project with the purpose of helping others learn Rust using a simple, but useful tool. 😊

In addition to studying Rust, this project has another goal — to promote love for open-source, help you with the first steps in it and give an opportunity to contribute to the open-source project written in Rust. ❤️

We act as a mentor within this project and help developers follow the path of a novice contributor from start to the top. 🤗

🤝 Contributing

If you've ever wanted to contribute to open source, now you have a great opportunity:

👍 Similar projects

Contributors

This project exists thanks to all the people who contribute. [Contribute].

♥️ Sponsors

Sponsored by Evrone

Become a financial contributor and help us sustain our community.

📃 License

MIT

Issues
  • Autofix

    Autofix

    I have implemented automatic correction of the contents of files based on the results of the check. When displaying, all warnings are marked as Fixed or Unfixed. If all warnings are fixed, exit code is 0.

    Just one kind of checks is fixable for now (LowercaseKey), but I have create the scaffold for implementing all kinds of checks.

    The CLI key for the autofix mode is -f/--fix.

    A few comments about the design:

    The separate trait Fix was made for fixes (I tried to keep some symmetry with checks), but it is possible to expand the trait Check itself with this functions too.

    There are two groups of fixes: some can be implemented by working only with the line that caused warning, for others you need to work with the entire line collection.

    The Fix trait allows you to work with both groups of fixes due to default function implementations.

    ✔ Checklist:

    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    • [x] Tests for the changes have been added (for bug fixes / features);
    • [x] Docs have been added / updated (for bug fixes / features).
    opened by evgeniy-r 34
  • WIP build: create docker arm64 image

    WIP build: create docker arm64 image

    Closes #449

    I hope this will work with GH-actions and the ubuntu-latest container. I used this locally to test some kubernetes stuff on different environments (arm64 and amd64 nodes) and it worked.

    Docker Buildx is included in Docker Desktop and Docker Linux packages when installed using the DEB or RPM packages.

    If you want to know more: https://docs.docker.com/buildx/working-with-buildx/

    ✔ Checklist:

    • [x] Commit messages have been written in Conventional Commits format;
    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    • [x] Tests for the changes have been added (for bug fixes / features);
    • [x] Docs have been added / updated on the dotenv-linter.github.io (for bug fixes / features).
    process stale 
    opened by mstruebing 28
  • Color output and --no-color option

    Color output and --no-color option

    This commit if included will:

    1. Adds color to warnings,
    2. Adds a --no-color option to switch off colored output,
    3. Adds a test case to cover --no-color option

    ✔ Checklist:

    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    • [x] Tests for the changes have been added (for bug fixes / features);
    • [ ] Docs have been added / updated (for bug fixes / features).
    wait hacktoberfest-accepted 
    opened by Nikhil0487 25
  • Add docs

    Add docs

    Used docsify to create the docs.

    You can take a look at the docs here where I pushed my fork branch.

    ✔ Checklist:

    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    opened by wesleimp 24
  • Add compare command

    Add compare command

    A proof of concept how comparing could work. I think this isn't the cleanest implementation and needs some abstraction work in terms of types, and duplicate work between compare and run but I wanted to see if it can work and how it could work.

    We didn't already agreed that this feature needed to be added to the tool, but I liked the idea, found some time and had fun playing around with it.

    So this could be the starting point of a discussion and further investigation of that topic.

    What do you think?

    Check this feature:

    # creating test data
    echo HELLO=value >> .env
    echo HELLO=value >> .env.local
    echo WORLD=value >> .env
    
    # running
    dotenv-linter --compare .env .env.local
    # or
    cargo run -- --compare .env .env.local
    
    feature 
    opened by mstruebing 23
  • Release v3.0.0

    Release v3.0.0

    What should be included in the new release v3.0.0.

    Features:

    • [x] Color output and --no-color option (#307)
    • [x] Display file names being scanned (#311)
    • [x] Add compare command (#282)
    • [x] Make an output on-the-fly (#335)
    • [x] Add support export prefix (#337)
    • [x] Add support multi-line values (#339)

    Improvements:

    • [x] Breaking changes: Using subcommands instead of flags (#333)
    • [x] Fix a bug with QuoteCharacterChecker and values with whitespaces (#343)
    • [x] Not all problems are found (#345)

    Infrastructure:

    Site:

    • [x] Add action-misspell (https://github.com/dotenv-linter/dotenv-linter.github.io/issues/17)
    • [x] Change flags to subcommands (https://github.com/dotenv-linter/dotenv-linter.github.io/issues/16)

    GitHub Action:

    • [x] Add action-shellcheck (https://github.com/dotenv-linter/action-dotenv-linter/issues/17)
    • [x] Add action-misspell (https://github.com/dotenv-linter/action-dotenv-linter/issues/16)
    • [x] Add --no-color flag (https://github.com/dotenv-linter/action-dotenv-linter/issues/21)

    What do you think should be included in the new release?

    /cc @dotenv-linter/core

    process 
    opened by mgrachev 20
  • UnorderedKey fix

    UnorderedKey fix

    PR for https://github.com/dotenv-linter/dotenv-linter/issues/252.

    ✔ Checklist:

    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    • [x] Tests for the changes have been added (for bug fixes / features);
    • [x] Docs have been added / updated (for bug fixes / features).
    opened by evgeniy-r 19
  • Provide more short way to install dotenv-linter

    Provide more short way to install dotenv-linter

    Implemented a script for more short way to install dotenv-linter (#112).

    The advantage of the solution is its cross-platform. The script is executed with curl/wget and even under Windows (checked on MINGW).

    Complexity is the process of automatically declaring an environment variable. In some cases, this is only possible manually at the moment.

    This is a working version, I also tested on Alpine Linux.

    But I would like to hear any ideas for improving or changing the approach.

    Perhaps when we come to a final decision, it makes sense to create a separate repository. Although for installing binaries with a script, it looks suitable in this repo, so far it is not more than 1 file.

    ✔ Checklist:

    • [X] This PR has been added to CHANGELOG.md (at the top of the list);
    • [X] Docs have been added / updated (for bug fixes / features).
    opened by DDtKey 19
  • Use Rc for Warning to reduce memory consumption

    Use Rc for Warning to reduce memory consumption

    Description

    The Warning struct has the LineEntry field which clones in every checks, e.g.: DuplicatedKeyChecker.

    Use the Rc type for Warning to reduce memory consumption.

    Similar issue: https://github.com/dotenv-linter/dotenv-linter/issues/388

    improvement 
    opened by mgrachev 18
  • Provide dotenv-linter in the Arch User Repository

    Provide dotenv-linter in the Arch User Repository

    The Arch User Repository is like a package repository for Arch linux maintained by it's users. I would be happy to set it up there so that any arch user can simply install it with:

    <your-aur-helper> -S dotenv-linter (-S is mostly the command to install a package, in case your aur helper does it differently you need to substitute this command.

    If that would be desired I would be happy to go :)

    opened by mstruebing 18
  • Shows files that were linted

    Shows files that were linted

    This PR adds functionality to show the files that were linted as part of a dotenv-linter run. It does so by introducing a new struct Warnings which is basically a wrapper around Vec<Warning> to also include information about the paths related to the warnings.

    This PR also fixes tests as a result of the added functionality, and some refactoring.

    Below shows the output from running dotenv-linter with different args:

    $ cargo run
    Checking ".env"
    .env:1 LowercaseKey: The hi key should be in uppercase
    .env:3 ExtraBlankLine: Extra blank line detected
    .env:4 LowercaseKey: The hi3 key should be in uppercase
    
    Checking ".env_2/.env"
    .env_2/.env:2 ExtraBlankLine: Extra blank line detected
    .env_2/.env:3 LowercaseKey: The hi key should be in uppercase
    .env_2/.env:4 DuplicatedKey: The hi key is duplicated
    .env_2/.env:4 LowercaseKey: The hi key should be in uppercase
    
    Found 7 problems
    
    $ cargo run -- -q
    .env:1 LowercaseKey: The hi key should be in uppercase
    .env:3 ExtraBlankLine: Extra blank line detected
    .env:4 LowercaseKey: The hi3 key should be in uppercase
    .env_2/.env:2 ExtraBlankLine: Extra blank line detected
    .env_2/.env:3 LowercaseKey: The hi key should be in uppercase
    .env_2/.env:4 DuplicatedKey: The hi key is duplicated
    .env_2/.env:4 LowercaseKey: The hi key should be in uppercase
    
    $ cargo run -- -f
    Checking ".env"
    Original file was backed up to: ".env_1601943961"
    
    .env:1 LowercaseKey: The hi key should be in uppercase
    .env:3 ExtraBlankLine: Extra blank line detected
    .env:4 LowercaseKey: The hi3 key should be in uppercase
    
    Checking ".env_2/.env"
    Original file was backed up to: ".env_2/.env_1601943961"
    
    .env_2/.env:2 ExtraBlankLine: Extra blank line detected
    .env_2/.env:3 LowercaseKey: The hi key should be in uppercase
    .env_2/.env:4 DuplicatedKey: The hi key is duplicated
    .env_2/.env:4 LowercaseKey: The hi key should be in uppercase
    
    All warnings are fixed. Total: 7
    
    $ cargo run -- -f -q
    Original file was backed up to: ".env_1601943979"
    Original file was backed up to: ".env_2/.env_1601943979"
    
    All warnings are fixed. Total: 7
    
    $ cargo run -- -f --no-backup
    Checking ".env"
    .env:1 LowercaseKey: The hi key should be in uppercase
    .env:3 ExtraBlankLine: Extra blank line detected
    .env:4 LowercaseKey: The hi3 key should be in uppercase
    
    Checking ".env_2/.env"
    .env_2/.env:2 ExtraBlankLine: Extra blank line detected
    .env_2/.env:3 LowercaseKey: The hi key should be in uppercase
    .env_2/.env:4 DuplicatedKey: The hi key is duplicated
    .env_2/.env:4 LowercaseKey: The hi key should be in uppercase
    
    All warnings are fixed. Total: 7
    
    $ cargo run -- -f -q --no-backup
    
    All warnings are fixed. Total: 7
    

    ✔ Checklist:

    • [x] This PR has been added to CHANGELOG.md (at the top of the list);
    • [x] Tests for the changes have been added (for bug fixes / features);
    • [x] Docs have been added / updated (for bug fixes / features).

    Closes #268

    wait hacktoberfest-accepted 
    opened by Anthuang 16
  • chore: bump clap from 3.1.10 to 3.2.16

    chore: bump clap from 3.1.10 to 3.2.16

    Bumps clap from 3.1.10 to 3.2.16.

    Release notes

    Sourced from clap's releases.

    v3.2.16

    [3.2.16] - 2022-07-30

    Fixes

    • Ensure required arguments appear in errors when they are also members of a group (#4004)

    v3.2.15

    [3.2.15] - 2022-07-25

    Features

    • (derive) New default_values_t and default_values_os_t attributes

    v3.2.14

    [3.2.14] - 2022-07-21

    Fixes

    • A multple_values positional followed by another positional now works with multiple flags

    v3.2.13

    [3.2.13] - 2022-07-19

    Documentation

    • Pulled in tutorials, cookbook, and derive reference into rustdoc

    v3.2.12

    [3.2.12] - 2022-07-14

    Fixes

    • Allow an arg to declare a conflict with a group

    v3.2.11

    [3.2.11] - 2022-07-13

    Features

    • Added Arg::get_all_short_aliaes and Arg::get_all_aliases

    v3.2.10

    [3.2.10] - 2022-07-12

    Fixes

    • Loosen lifetime on Command::mut_subcommand

    v3.2.8

    ... (truncated)

    Changelog

    Sourced from clap's changelog.

    [3.2.16] - 2022-07-30

    Fixes

    • Ensure required arguments appear in errors when they are also members of a group (#4004)

    [3.2.15] - 2022-07-25

    Features

    • (derive) New default_values_t and default_values_os_t attributes

    [3.2.14] - 2022-07-21

    Fixes

    • A multple_values positional followed by another positional now works with multiple flags

    [3.2.13] - 2022-07-19

    Documentation

    • Pulled in tutorials, cookbook, and derive reference into rustdoc

    [3.2.12] - 2022-07-14

    Fixes

    • Allow an arg to declare a conflict with a group

    [3.2.11] - 2022-07-13

    Features

    • Added Arg::get_all_short_aliaes and Arg::get_all_aliases

    [3.2.10] - 2022-07-12

    Fixes

    • Loosen lifetime on Command::mut_subcommand

    [3.2.8] - 2022-06-30

    Features

    • Added Command::mut_subcommand to mirror Command::mut_arg

    [3.2.7] - 2022-06-28

    ... (truncated)

    Commits
    • 9bd1e2f chore: Release
    • 5e52594 docs: Update changelog
    • 80ea08c Merge pull request #4006 from epage/error
    • 4c43b21 fix(parser): Include required argument in message
    • ef1424b refactor(usage): Clarify required gathering
    • b2a8fd7 chore: Release
    • 026e858 chore: Allow releasing from release branches
    • 84ae6df docs: Update changelog
    • 69b0904 Merge pull request #3987 from emersonford/default-values-t-v3-backport
    • 027a675 feat(clap_derive): Add default_values_t and default_values_os_t
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Add `version` (argument) pattern check

    Add `version` (argument) pattern check

    curl -sSfL https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s -b usr/local/bin
    dotenv-linter installer: Version usr/local/bin will be installed
    curl: (22) The requested URL returned error: 404
    dotenv-linter installer: Failed to download file https://github.com/dotenv-linter/dotenv-linter/releases/download/usr/local/bin/dotenv-linter-darwin-x86_64.tar.gz
    
    help wanted 
    opened by vkaramov 3
  • Automatic changelog adding of new commits on merge in master

    Automatic changelog adding of new commits on merge in master

    Currently, everyone needs to add their changes themselves to the CHANGELOG.md file. As this is tedious work it would be great if that could be automated via a github action on merge in master or something like that.

    help wanted good first issue 
    opened by mstruebing 6
Releases(v3.2.0)
Owner
dotenv-linter
⚡️Lightning-fast linter for .env files. Written in Rust 🦀
dotenv-linter
udbg's windows driver written in rust

This is the code of windows driver used in udbg, it contains the basic function used in udbg's 'krnl' adaptor, such as memory read/write, and it integ

null 3 Nov 3, 2021
Shellcode loader written in rust. Strives to evade modern EDR solutions.

Pestilence What is pestilence? Pestilence is a shellcode loader written in rust. It strives to evade modern EDR solutions. How does it work? It loads

Daniil Nababkin 22 Jul 29, 2022
Backtrace support for Rust `no_std` and embedded programs.

mini-backtrace This crate provides backtrace support for no_std and embedded programs. This is done through by compiling LLVM's libunwind with certain

Amanieu d'Antras 23 Jul 31, 2022
Rust External Cheat

rust-external-cheat Rust External Cheat neden bu projedesiniz hemen anlatayım; daha type casting nedir bilmeyen pasterların pastelediği sourcedir. tam

Orçun 23 Jun 27, 2022
rlua -- High level bindings between Rust and Lua

rlua -- High level bindings between Rust and Lua

Amethyst Foundation 1.3k Aug 3, 2022
Just storing all my codes in Rust here (learning)

Rust-Dump I am learning Rust in 2021, and this will take some time. The end goal is to be able to understand the codebase of PopOS and contribute. I'l

Kushashwa Ravi Shrimali 3 Nov 3, 2021
Integration of Rust code with a C Kernel Module

Rust-Kernel-Mod Description Integration of Rust code with a C Kernel Module This project sets up a minimalistic Linux kernel module in C which it uses

Dylan Turner 1 Nov 1, 2021
A kdmapper library for Rust

A kdmapper library for Rust Needed to integrate TheCruZ/kdmapper into one of my projects, so I made a library that will let me integrate kdmapper into my Rust code

Ryan McCrystal 7 Jul 18, 2022
Minimal freestanding C library for kernel dev. Think Rust's libcore but for C. (memutils, string formatting, etc)

Libcore Minimal freestanding C library. Features String formatting. Memory utils memcpy memmove memcmp String utils strlen strncpy strncmp Serial driv

Anthony 3 Oct 21, 2021
Tests to check the determinism of the basic floating point arithmetic operations on different devices, using Unity and Rust.

This repo contains tests to check the determinism (consistency) of the basic floating point arithmetic operations (add, subtract, multiply, divide) on

Erik Roystan 4 Dec 24, 2021
A simple tool used to upgrade things quicker in the online game Rust.

ex0 Rust Tool ??️ What is this? ⚡ This is a simple script with multiple tools such as a code enterer and a auto upgrade feature! ??️ Features ⚡ Any se

Alfie 3 Jan 1, 2022
A package manager for C++, like Cargo for Rust.

Description Poac is a package manager for C++ users. Poac can download project's dependencies and compile a project. Please see poac.pm, installation

Poac 530 Aug 1, 2022
C, C++, D, Fortran, Rust and Zig for your z80

z80 Babel: C, C++, D, Fortran, Rust and Zig for your z80 This is a proof of concept for a multi-language pipeline for the Z80 CPU, and its correspondi

Manuel Martinez Torres 13 Jul 26, 2022
This program converts ASCII STL files to RT files for miniRT.

STL to RT This program converts ASCII STL files to RT files for miniRT. Input the ASCII STL file to the standard input and output the RT file from the

null 5 Mar 29, 2021
Use DOS object files (OMF) as patch files

omfpatch - Use Intel/Microsoft .OBJ files as binary diffs Overview This tool makes it possible to use MASM / TASM / JWasm / nasm as tool to write patc

Michael Karcher 2 Jan 30, 2022
Creates 3D lithophanes from image files, exports them to stl files, ready for slicing and 3D printing.

LithoMaker Creates 3D lithophanes from PNG image files and exports them to STL files, ready for slicing and 3D printing. Download the latest release h

Lars Muldjord 13 Jun 29, 2022
Just a basic mini library for parsing simple files that only have variables written and with Lua extension.

C++ Parser Lua file config Just a basic mini library for parsing simple files that only have variables written and with Lua extension. Note: At the mo

Marcos Oliveira 3 Dec 26, 2021
Peregrine - A blazing fast language for the blazing fast world(WIP)

A Blazing-Fast Language for the Blazing-Fast world. The Peregrine Programming Language Peregrine is a Compiled, Systems Programming Language, currentl

Peregrine 1.5k Jul 28, 2022
Pandex is a light but FAST programming language written in C . Pandex goal is that be hard & it's good for eductional goals

The Pandex programming language version 1.0.0.3 Pandex versions release type The Pandex version has four numbers. the first number holds 1 ( or 0 in s

null 8 May 23, 2022