View Source Warnex (warnex v0.2.0)

This module is meant to assist in ordering the warnings outputted by this application.

Initially, you must gather the warnings from the compilation output:

  rm warnings.log; mix compile --force --all-warnings > warnings.log 2>&1

  OR

  alias Warnex
  Warnex.generate_warnings()

Summary

Functions

Shows all warning counts for all files with warnings

Returns the total amount of errors for a specific file

Returns the warnings for a specific file lookup

Returns all warnings where the existing warning contains the given string

Runs the compilation process and generates the warnings.log file. Returns :ok if successful, {:error, reason} if the command fails.

Gives you the next n file warnings

Parses the log output of a compilation into maps

Describes the total warnings for all files that have warnings

Functions

count()

Shows all warning counts for all files with warnings

Examples

iex(1)> Warnex.count
8

count(lookup)

Returns the total amount of errors for a specific file

Example

iex(1)> Warnex.count("shared_view.ex")
1

for_file(lookup)

Returns the warnings for a specific file lookup

Examples

iex(1)> Warnex.for_file("shared_view.ex")
[
  %{
    message: "missing parentheses for expression following "else:" keyword. Parentheses are required to solve ambiguity inside keywords.",
    location: %{
      line: 11,
      filename: "shared_view.ex",
      path: "lib/application_web/views"
    }
  },
  %{...},
  ...
]

for_warning(warning)

Returns all warnings where the existing warning contains the given string

Examples

iex(1)> Warnex.for_warning("missing parentheses for expression")
%{
  "shared_view.ex" => [
    %{
      message: "missing parentheses for expression following "else:" keyword. Parentheses are required to solve ambiguity inside keywords.",
      location: %{
        line: 11,
        filename: "shared_view.ex",
        path: "lib/application_web/views"
      }
    }
  ],
  "..." => [...]
}

generate_warnings()

Runs the compilation process and generates the warnings.log file. Returns :ok if successful, {:error, reason} if the command fails.

Examples

iex> Warnex.generate_warnings()
:ok

next(n)

Gives you the next n file warnings

Examples

iex(1)> Warnex.next(5)

[
  [
    %{
      message: "missing parentheses for expression following "else:" keyword. Parentheses are required to solve ambiguity inside keywords.",
      location: %{
        line: 11,
        filename: "shared_view.ex",
        path: "lib/application_web/views"
      }
    }
  ],
[...],
...
]

parse_warnings()

Parses the log output of a compilation into maps

Examples

iex(1)> Warnex.parse_warnings()
[
  %{
    message: "variable "result" is unused (if the variable is not meant to be used, prefix it with an underscore)",
    location: %{
      line: 44,
      filename: "recurring_call_job_status_cache.ex",
      path: "lib/core_blayze_app/cache"
    }
  },
  %{...},
  ...
]

summary()

Describes the total warnings for all files that have warnings

Examples

iex(1)> Warnex.summary
[
  ["shared_view.ex", 1],
  ["page_controller.ex", 1],
  ["items.ex", 1],
]