All Projects → karolsluszniak → Ex_check

karolsluszniak / Ex_check

Licence: mit
One task to efficiently run all code analysis & testing tools in an Elixir project. Born out of 💜 to Elixir and pragmatism.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Ex check

Jsinspect
Detect copy-pasted and structurally similar code
Stars: ✭ 3,379 (+1606.57%)
Mutual labels:  clean-code, code-analysis
Typo3 Console
Console command for TYPO3 CMS
Stars: ✭ 254 (+28.28%)
Mutual labels:  command-line-tool, continuous-integration
Xcov
Nice code coverage reporting without hassle
Stars: ✭ 467 (+135.86%)
Mutual labels:  command-line-tool, continuous-integration
Circleci Cli
Use CircleCI from the command line
Stars: ✭ 297 (+50%)
Mutual labels:  command-line-tool, continuous-integration
Churn Php
Discover files in need of refactoring.
Stars: ✭ 1,051 (+430.81%)
Mutual labels:  clean-code, continuous-integration
Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (-8.59%)
Mutual labels:  code-analysis
Wflow
🐆 EXPERIMENTAL -- Runs GitHub Actions workflows locally (local) -- Don't run your YAML like a 🐪
Stars: ✭ 187 (-5.56%)
Mutual labels:  continuous-integration
Env Ci
Get environment variables exposed by CI services
Stars: ✭ 180 (-9.09%)
Mutual labels:  continuous-integration
You Dont Need Gui
Stop relying on GUI; CLI **ROCKS**
Stars: ✭ 4,766 (+2307.07%)
Mutual labels:  command-line-tool
Tnote
📋 A command line note taking app so simple that even your grandparents will love it!
Stars: ✭ 195 (-1.52%)
Mutual labels:  command-line-tool
Tq
Perform a lookup by CSS selector on an HTML input
Stars: ✭ 193 (-2.53%)
Mutual labels:  command-line-tool
Icon Font To Png
Python script (and library) for exporting icons from icon fonts (e.g. Font Awesome, Octicons) as PNG images
Stars: ✭ 186 (-6.06%)
Mutual labels:  command-line-tool
Cirrus Ci Docs
Documentation for Cirrus CI 📚
Stars: ✭ 180 (-9.09%)
Mutual labels:  continuous-integration
Clean Code Javascript
🛁 Адаптированные для JavaScript концепции Чистого кода
Stars: ✭ 187 (-5.56%)
Mutual labels:  clean-code
Tooling
🧰 Up-to-date list of JavaScript and TypeScript tooling resources
Stars: ✭ 181 (-8.59%)
Mutual labels:  continuous-integration
Toolbox
Simplifies common command line tasks when using Vapor
Stars: ✭ 194 (-2.02%)
Mutual labels:  command-line-tool
Autosubsync
Automatically synchronize subtitles with audio using machine learning
Stars: ✭ 179 (-9.6%)
Mutual labels:  command-line-tool
Gitbuddy
Your buddy in managing and maintaining GitHub repositories, and releases. Automatically generate changelogs from issues and merged pull-requests.
Stars: ✭ 184 (-7.07%)
Mutual labels:  command-line-tool
Comics Downloader
tool to download comics and manga in pdf/epub/cbr/cbz from a website
Stars: ✭ 190 (-4.04%)
Mutual labels:  command-line-tool
Pywarm
A cleaner way to build neural networks for PyTorch.
Stars: ✭ 184 (-7.07%)
Mutual labels:  clean-code

ex_check

Hex version Build status (GitHub) Build status (Travis) Downloads License

Demo

Run all code checking tools with a single convenient mix check command.


Takes seconds to setup, saves hours in the long term.

Sports powerful features to enable ultimate flexibility.

Takes care of the little details, so you don't have to.

  • Compiles the project and collects compilation warnings in one go
  • Ensures that output from tools is ANSI formatted & colorized
  • Retries ExUnit with the --failed flag

Read more in the introductory "One task to rule all Elixir analysis & testing tools" article.

Getting started

Add ex_check dependency in mix.exs:

def deps do
  [
    {:ex_check, "~> 0.14.0", only: [:dev], runtime: false}
  ]
end

Fetch the dependency:

mix deps.get

Run the check:

mix check

That's it - mix check will detect and run all the available tools.

Community tools

If you want to take advantage of community curated tools, add following dependencies in mix.exs:

def deps do
  [
    {:credo, ">= 0.0.0", only: [:dev], runtime: false},
    {:dialyxir, ">= 0.0.0", only: [:dev], runtime: false},
    {:doctor, ">= 0.0.0", only: [:dev], runtime: false},
    {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false},
    {:sobelow, ">= 0.0.0", only: [:dev], runtime: false}
  ]
end

You may also generate .check.exs to adjust the check:

mix check.gen.config

Among others, this allows to permamently disable specific tools and avoid the skipped notices.

[
  tools: [
    {:dialyzer, false},
    {:sobelow, false}
  ]
]

Local-only fix mode

You should keep local and CI configuration as consistent as possible by putting together the project-specific .check.exs. Still, you may introduce local-only config by creating the ~/.check.exs file. This may be useful to enforce global flags on all local runs. For example, the following config will enable the fix mode in local (writeable) envirnoment:

[
  fix: true
]

You may also enable the fix mode on the CI.

Documentation

Learn more about the tools included in the check as well as its workflow, configuration and options on HexDocs or by running mix help check.

Want to write your own code check? Get yourself started by reading the "Writing your first Elixir code check" article.

Continuous Integration

With mix check you can consistently run the same set of checks locally and on the CI. CI configuration also becomes trivial and comes out of the box with parallelism and error output from all checks at once regardless of which ones have failed.

Like on a local machine, all you have to do in order to use ex_check on CI is run mix check nstead of mix test. This repo features working CI configs for following providers:

Yes, ex_check uses itself on the CI. Yay for recursion!

Autofixing

You may automatically fix and commit back trivial issues by triggering the fix mode on the CI as well. In order to do so, you'll need a CI script or workflow similar to the example below:

mix check --fix && \
  git diff-index --quiet HEAD -- && \
  git config --global user.name 'Autofix' && \
  git config --global user.email '[email protected]' && \
  git add --all && \
  git commit --message "Autofix" && \
  git push

First, we perform the check in the fix mode. Then, if no unfixable issues have occurred and if fixes were actually made, we proceed to commit and push these fixes.

Of course your CI will need to have write permissions to the source repository.

Random failures

You may take advantage of the automatic retry feature to efficiently re-run failed tools & tests multiple times. For instance, following shell command runs check up to three times: mix check || mix check || mix check. And here goes an alternative without the logical operators:

mix check
mix check --retry
mix check --retry

This will work as expected because the --retry flag will ensure that only failed tools are executed, resulting in no-op if previous run has succeeded.

Troubleshooting

Duplicate builds

If, as suggested above, you've added ex_check and curated tools to only: [:dev], you're keeping the test environment reserved for ex_unit. While a clean setup, it comes at the expense of Mix having to compile your app twice - in order to prepare :test build just for ex_unit and :dev build for other tools. This costs precious time both on local machine and on the CI. It may also cause issues if you set MIX_ENV=test, which is a common practice on the CI.

You may avoid this issue by running mix check and all the tools it depends on in the test environment. In such case you may want to have the following config in mix.exs:

def project do
  [
    # ...
    preferred_cli_env: [
      check: :test,
      credo: :test,
      dialyzer: :test,
      doctor: :test,
      sobelow: :test
    ]
  ]
end

def deps do
  [
    {:credo, ">= 0.0.0", only: [:test], runtime: false},
    {:dialyxir, ">= 0.0.0", only: [:test], runtime: false},
    {:doctor, ">= 0.0.0", only: [:test], runtime: false},
    {:ex_check, "~> 0.14.0", only: [:test], runtime: false},
    {:ex_doc, ">= 0.0.0", only: [:dev, :test], runtime: false},
    {:sobelow, ">= 0.0.0", only: [:test], runtime: false}
  ]
end

And the following in .check.exs:

[
  tools: [
    {:compiler, env: %{"MIX_ENV" => "test"}},
    {:formatter, env: %{"MIX_ENV" => "test"}},
    {:ex_doc, env: %{"MIX_ENV" => "test"}}
  ]
]

Above setup will consistently check the project using just the test build, both locally and on the CI.

unused_deps false negatives

You may encounter an issue with the unused_deps check failing on the CI while passing locally, caused by fetching only dependencies for specific env. If that happens, remove the --only test (or similar) from your mix deps.get invocation on the CI to fix the issue.

Changelog

See CHANGELOG.md.

License

See LICENSE.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].