credo v1.3.0 Release Notes

Release Date: 2020-03-09 // about 4 years ago
    • 0๏ธโƒฃ Enable Credo.Check.Readability.UnnecessaryAliasExpansion check by default
    • ๐Ÿ›  Fix bugs when removing heredocs and charlists from sources
    • ๐Ÿ›  Fix false positive on TrailingWhiteSpace
    • โž• Add ignore: [:fun1, :fun2] param to all UnusedOperation* checks; to ignore unused Enum.reduce/3 operations, use

      {Credo.Check.Warning.UnusedEnumOperation, [ignore: [:reduce]]},

    ๐Ÿ†• New switch to re-enable disabled checks

    ๐Ÿ‘‰ Use --enable-disabled-checks [pattern] to re-enable checks that were disabled in the config using {CheckModule, false}. This comes in handy when using checks on a case-by-case basis

    As with other check-related switches, pattern is a comma-delimted list of patterns:

    $ mix credo info --enable-disabled-checks Credo.Check.Readability.Specs,Credo.Check.Refactor.DoubleBooleanNegation
    

    Of course, we can have the same effect by choosing the pattern less explicitly:

    $ mix credo info --enable-disabled-checks specs,double
    

    ๐Ÿ†• New API for custom checks

    ๐Ÿ—„ > This deprecates the mandatory use of @explanation and @default_params module attributes for checks.

    0๏ธโƒฃ Before v1.3 you had to define module attributes named @explanation and @default_params before calling use Credo.Check.

    0๏ธโƒฃ Now you can pass :explanations (plural) and :param_defaults options directly to use Credo.Check.

    defmodule MyCheck do
      use Credo.Check,
        category: :warning,
        base_priority: :high,
        param_defaults: [param1: 42, param2: "offline"],
        explanations: [
          check: "...",
          params: [
            param1: "Your favorite number",
            param2: "Online/Offline mode"
          ]
        ]
    
      def run(%SourceFile{} = source_file, params) do
        #
      end
    end
    

    Please note that these options are also just a convenience to implement the functions specified by the Credo.Check behaviour. You can alternatively implement the respective functions yourself:

    defmodule MyCheck do
      use Credo.Check
    
      def category, do: :warning
    
      def base_priority, do: :high
    
      def explanations do
        [
          check: "...",
          params: [
            param1: "Your favorite number",
            param2: "Online/Offline mode"
          ]
        ]
      end
    
      def param_defaults, do: [param1: 42, param2: "offline"]
    
      def run(%SourceFile{} = source_file, params) do
        #
      end
    end
    

    ๐Ÿ†• New checks

    • Credo.Check.Readability.StrictModuleLayout
    • Credo.Check.Readability.WithCustomTaggedTuple
    • โš  Credo.Check.Warning.LeakyEnvironment
    • โš  Credo.Check.Warning.UnsafeExec