MetaCredo.Config (MetaCredo v0.1.0)

View Source

Parses and manages .metacredo.exs configuration files.

Configuration follows the same shape as .credo.exs:

%{
  configs: [
    %{
      name: "default",
      files: %{
        included: ["lib/", "src/"],
        excluded: ["deps/", "_build/"]
      },
      checks: %{
        enabled: [
          {MetaCredo.Check.Security.HardcodedValue, []},
          {MetaCredo.Check.Warning.MissingErrorHandling, []}
        ],
        disabled: []
      }
    }
  ]
}

Summary

Functions

Returns the default configuration.

Returns the path to the default configuration file.

Returns the list of enabled checks from config.

Returns the file patterns from config.

Reads and parses the configuration file, falling back to defaults.

Types

config()

@type config() :: %{
  name: String.t(),
  files: %{included: [String.t()], excluded: [String.t() | Regex.t()]},
  checks: %{
    enabled: [{module(), Keyword.t()}] | :all,
    disabled: [{module(), Keyword.t()}]
  }
}

Functions

default()

@spec default() :: config()

Returns the default configuration.

default_config_path()

@spec default_config_path() :: String.t()

Returns the path to the default configuration file.

enabled_checks(map)

@spec enabled_checks(config()) :: [{module(), Keyword.t()}]

Returns the list of enabled checks from config.

file_patterns(map)

@spec file_patterns(config()) :: %{included: [String.t()], excluded: [term()]}

Returns the file patterns from config.

read(config_file \\ nil)

@spec read(String.t() | nil) :: config()

Reads and parses the configuration file, falling back to defaults.