Giter Site home page Giter Site logo

meandro's Introduction

Meandro Build Status Hex pm

Find dead code in Elixir applications

a spiraling oxbow lake, in the style of Salvador Dalí

What kind of dead code? Meandro currently has rules to find:

  • unused function arguments
  • unused struct fields
  • unused record fields
  • unused configuration options
  • unused callbacks
  • unused macros

Sample Output

If Meandro detects issues in your code, it will report them as follows…

lib/cache.ex:23 |> execute/1 doesn't need its #1 argument
lib/application.ex:15 |> maybe_evaluate/2 doesn't need its #1 argument
lib/application.ex:45 |> maybe_evaluate/3 doesn't need its #2 argument
Config files |> Configuration option :color (MIX_ENV=dev) is not used anywhere in the code

Installation

The package can be installed from hex by adding meandro to your list of dependencies in mix.exs:

def deps do
  [
    {:meandro, "~> 0.1.0"}
  ]
end

The docs can be found at https://hexdocs.pm/meandro.

Usage

mix meandro

is the basic command. It'll run all configured rules (which is all of them by default) against all of the *.ex files in your application.

You can pass the --files argument if you'd like to check only particular files.

mix meandro --files lib/foo.ex,lib/bar.ex

Be warned, however, that it will only look at those files. Functions declared in those files but used elsewhere will be seen as "unused."

Configuration

The plugin supports the following configuration options in the meandro section of mix.exs:

  • rules ([Meandro.Rule.t()]):
    • This is the list of rules to apply to the analyzed code. Each rule is a module that should apply the Meandro.Rule behavior.
    • If this option is not defined, meandro will apply all of the default rules.
  • parsing (Meandro.Util.parsing_style()):
    • This parameter determines if meandro should parse files in a parallel (mapping through Task.async/1) or sequential (plain Enum.map/2) fashion.
    • The default value is parallel since it's faster.
  • ignore ([Path.t() | {Path.t(), Meandro.Rule.t() | [Meandro.Rule.t()]} | {Path.t(), Meandro.Rule.t() | [Meandro.Rule.t()], list()}]):
    • List of wildcard patterns representing the files and rules that meandro will ignore when analyzing. Tuple format is used to ignore either a specific rule or a set of rules in those files.

Example

  def project do
    [
      meandro: meandro_config(),
      ...
    ]
  end

  def meandro_config() do
    %{
      rules: [Meandro.Rule.UnnecessaryFunctionArguments],
      parsing: :sequential,
      ignore: ["test/example.ex"]
    }
  end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.