From 64de472dbf3cb07d7d0034c9aed6fdc8f69c7dfa Mon Sep 17 00:00:00 2001 From: Luke Fishman Date: Wed, 29 Jan 2025 12:52:19 +0700 Subject: [PATCH] use take error: egative steps are not supported in Enum.slice/2, pass 0..-4//1 instead (elixir 1.17.2) lib/enum.ex:3000: Enum.slice/2 (meandro 0.1.0) lib/meandro/meandro_config_parser.ex:114: Meandro.ConfigParser.rule_files/0 (meandro 0.1.0) lib/meandro/meandro_config_parser.ex:107: Meandro.ConfigParser.default_rules/0 (meandro 0.1.0) lib/meandro/meandro_config_parser.ex:32: Meandro.ConfigParser.parse_config/1 Signed-off-by: Luke Fishman --- lib/meandro/meandro_config_parser.ex | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/meandro/meandro_config_parser.ex b/lib/meandro/meandro_config_parser.ex index ec935ca..0767ac9 100644 --- a/lib/meandro/meandro_config_parser.ex +++ b/lib/meandro/meandro_config_parser.ex @@ -108,12 +108,18 @@ defmodule Meandro.ConfigParser do do: Meandro.Util.module_name_from_file_path(file) end - defp rule_files() do - __ENV__.file - |> Path.split() - |> Enum.slice(0..-4) +defp rule_files() do + path_parts = Path.split(__ENV__.file) + + if length(path_parts) >= 4 do + path_parts + |> Enum.take(length(path_parts) - 3) # Equivalent to 0..-4 |> Path.join() |> Path.join(@rules_wildcard) |> Path.wildcard() + else + [] end end + +end