Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - travis build fails relating to Elixir.Credo.Check.Consistency.SpaceAroundOperators #463

Closed
lulu-2021 opened this issue Oct 11, 2017 · 6 comments

Comments

@lulu-2021
Copy link

A project of mine fails to build in travis due to credo crashing - am unable to replicate this locally

Environment

  • Credo version (mix credo -v):
  • Erlang/Elixir version (elixir -v): 1.5
  • Operating system: Debian Linux (whatever travis CI currently runs by default..)

What were you trying to do?

Build this project in travis

https://github.com/netflakes/content_indexer

it runs this build & test sequence in travis CI:

MIX_ENV=test mix do deps.get, compile, credo --strict, test

Expected outcome

build to pass in travis ci - am not able to replicate this locally

Actual outcome

Error while running Elixir.Credo.Check.Consistency.SpaceAroundOperators

** (EXIT from #PID<0.74.0>) an exception was raised:

** (MatchError) no match of right hand side value: {:ok, [{:identifier, {1, {1, 10}, nil}, :defmodule}, {:alias, {1, {11, 25}, nil}, :ContentIndexer}, {:do, {1, {26, 28}, nil}}, {:eol, {1, {28, 29}, 1}}, {:at_op, {2, {3, 4}, nil}, :@}, {:identifier, {2, {4, 13}, nil}, :moduledoc}, {:bin_heredoc, {2, {14, 1}, nil}, ["Documentation for ContentIndexer.\n"]}, {:eol, {4, {1, 2}, 1}}, {:identifier, {5, {3, 6}, nil}, :use}, {:alias, {5, {7, 18}, nil}, :Application}, {:eol, {5, {18, 19}, 1}}, {:identifier, {8, {3, 6}, nil}, :def}, {:paren_identifier, {8, {7, 12}, nil}, :start}, {:"(", {8, {12, 13}, nil}}, {:identifier, {8, {13, 18}, nil}, :_type}, {:",", {8, {18, 19}, 0}}, {:identifier, {8, {20, 25}, nil}, :_args}, {:")", {8, {25, 26}, nil}}, {:do, {8, {27, 29}, nil}}, {:eol, {8, {29, 30}, 1}}, {:identifier, {9, {5, 11}, nil}, :import}, {:alias, {9, {12, 22}, nil}, :Supervisor}, {:., {9, {22, 23}, nil}}, {:alias, {9, {23, 27}, nil}, :Spec}, {:",", {9, {27, 28}, 0}}, {:kw_identifier, {9, {29, 34}, nil}, :warn}, {false, {9, {35, 40}, nil}}, {:eol, {9, {40, 41}, 1}}, {:identifier, {12, {5, 13}, nil}, :children}, {:match_op, {12, {14, 15}, nil}, :=}, {:"[", {12, {16, 17}, nil}}, {:eol, {12, {17, 18}, 1}}, {:paren_identifier, {13, {7, 13}, nil}, :worker}, {:"(", {13, {13, 14}, nil}}, {:alias, {13, {14, 28}, nil}, :ContentIndexer}, {:., {13, {28, 29}, nil}}, {:alias, {13, {29, 37}, nil}, :Services}, {:., {13, {37, 38}, nil}}, {:alias, {13, {38, 48}, nil}, :Calculator}, {:",", {13, {48, 49}, 0}}, {:"[", {13, {50, 51}, nil}}, {:"]", {13, {51, 52}, nil}}, {:")", {13, {52, ...}, nil}}, {:",", {13, {...}, ...}}, {:paren_identifier, {14, ...}, :worker}, {:"(", {...}}, {:alias, ...}, {...}, ...]}

    lib/credo/code.ex:104: Credo.Code.to_tokens/1

    lib/credo/check/consistency/space_around_operators/collector.ex:10: Credo.Check.Consistency.SpaceAroundOperators.Collector.collect_matches/2

    lib/credo/check/consistency/collector.ex:126: anonymous fn/3 in Credo.Check.Consistency.Collector.find_issues/4

    (elixir) lib/enum.ex:1306: Enum."-map/2-lists^map/1-0-"/2

    lib/credo/check/consistency/collector.ex:125: Credo.Check.Consistency.Collector.find_issues/4

    lib/credo/check/consistency/space_around_operators/collector.ex:2: Credo.Check.Consistency.SpaceAroundOperators.Collector.find_and_append_issues/4

    lib/credo/check/runner.ex:148: Credo.Check.Runner.run_check/3

    (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
@pragdave
Copy link

This is happening for me, too. In my case it happens on my local machine:

The project contains only lib/kv.ex:

defmodule KV do
end

Running credo 0.8.8 I get:

~/t/kv
19∙48∙27≻ mix credo
Checking 1 source file ...
Error while running Elixir.Credo.Check.Consistency.SpaceAroundOperators
** (EXIT from #PID<0.73.0>) an exception was raised:
    ** (MatchError) no match of right hand side value: {:ok, [{:identifier, {1
, {1, 10}, nil}, :defmodule}, {:alias, {1, {11, 13}, nil}, :KV}, {:do, {1, {14
, 16}, nil}}, {:eol, {1, {16, 17}, 1}}, {:end, {2, {1, 4}, nil}}, {:eol, {2, {
4, 5}, 1}}]}                                                                 
        lib/credo/code.ex:104: Credo.Code.to_tokens/1
        lib/credo/check/consistency/space_around_operators/collector.ex:10: Credo.Check.Consistency.SpaceAroundOperators.Collector.collect_matches/2       
        lib/credo/check/consistency/collector.ex:126: anonymous fn/3 in Credo.
Check.Consistency.Collector.find_issues/4                                    
        (elixir) lib/enum.ex:1270: Enum."-map/2-lists^map/1-0-"/2
        lib/credo/check/consistency/collector.ex:125: Credo.Check.Consistency.
Collector.find_issues/4                                                      
        lib/credo/check/consistency/space_around_operators/collector.ex:2: Credo.Check.Consistency.SpaceAroundOperators.Collector.find_and_append_issues/4 
        lib/credo/check/runner.ex:148: Credo.Check.Runner.run_check/3
        (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2

(followed by a bunch of OTP spew)

Elixir 1.6.0-dev (dd4fd6ab742acd75862e34e26dbdb86e0cf6453f)

Let me know if I can help with the diagnosis by running stuff here.

Dave

@AndrewDryga
Copy link
Contributor

I happens to me too:

mix credo             
Checking 6 source files ...
Error while running Elixir.Credo.Check.Consistency.SpaceAroundOperators
** (EXIT from #PID<0.73.0>) an exception was raised:
    ** (MatchError) no match of right hand side value: {:ok, [{:identifier, {1, {1, 10}, nil}, :defmodule}, {:alias, {1, {11, 17}, nil}, :Confex}, {:do, {1, {18, 20}, nil}}, {:eol, {1, {20, 21}, 1}}, {:at_op, {2, {3, 4}, nil}, :@}, {:identifier, {2, {4, 13}, nil}, :moduledoc}, {:bin_heredoc, {2, {14, 1}, nil}, ["Confex simplifies reading configuration at run-time with adapter-based system for resolvers.\n\n# Configuration tuples\n\nWhenever there is a configuration that should be resolved at run-time you need to replace it's value in `config.exs`\nby Confex configuration type. Common structure:\n\n  ```elixir\n  @type fetch_statement :: {adapter :: atom() | module(), value_type :: value_type, key :: String.t, default :: any()}\n                         | {value_type :: value_type, key :: String.t}\n                         | {key :: String.t, default :: any()}\n                         | {key :: String.t}\n  ```\n\nIf `value_type` is set, Confex will automatically cast it's value. Otherwise, default type of `:string` is used.\n\n| Confex Type | Elixir Type       | Description |\n| ----------- | ----------------- | ----------- |\n| `:string`   | `String.t`        | Default.    |\n| `:integer`  | `Integer.t`       | Parse Integer value in string. |\n| `:float`    | `Float.t`         | Parse Float value in string. |\n| `:boolean`  | `true` or `false` | Cast 'true', '1', 'yes' to `true`; 'false', '0', 'no' to `false`. |\n| `:atom`     | `atom()`          | Cast string to atom. |\n| `:module`   | `module()`        | Cast string to module name. |\n| `:list`     | `List.t`          | Cast comma-separated string (`1,2,3`) to list (`[1, 2, 3]`). |\n\n# Custom type casting\n\nYou can use your own casting function by replacing type with `{module, function, arguments}` tuple,\nConfex will call that function with `apply(module, function, [value] ++ arguments)`.\n\nThis function returns either `{:ok, value}` or `{:error, reason :: String.t}` tuple.\n\n# Adapters\n\n  * `:system` - read configuration from system environment;\n  * `:system_file` - read file path from system environment and read configuration from this file.\n\nYou can create adapter by implementing `Confex.Adapter` behaviour with your own logic.\n\n# Examples\n\n  * `var` - any bare values will be left as-is;\n  * `{:system, \"ENV_NAME\", default}` - read string from \"ENV_NAME\" environment variable or return `default`   if it's not set or has empty value;\n  * `{:system, \"ENV_NAME\"}` - same as above, with default value `nil`;\n  * `{:system, :integer, \"ENV_NAME\", default}` - read string from \"ENV_NAME\" environment variable and cast it   to integer or return `default` if it's not set or has empty value;\n  * `{:system, :integer, \"ENV_NAME\"}` - same as `{:system, :integer, \"ENV_NAME\", nil}`;\n  * `{{:via, MyAdapter}, :string, \"ENV_NAME\", default}` - read value by key \"ENV_NAME\" via adapter `MyAdapter`   or return `default` if it's not set or has empty value;\n  * `{{:via, MyAdapter}, :string, \"ENV_NAME\"}` - same as above, with default value `nil`;\n  * `{:system, {MyApp.MyType, :cast, [:foo]}, \"ENV_NAME\"}` - `MyApp.MyType.cast(value, :foo)` call would be made   to resolve environment variable value.\n"]}, {:eol, {57, {1, 2}, 1}}, {:identifier, {58, {3, 8}, nil}, :alias}, {:alias, {58, {9, 15}, nil}, :Confex}, {:., {58, {15, 16}, nil}}, {:alias, {58, {16, 24}, nil}, :Resolver}, {:eol, {58, {24, 25}, 2}}, {:at_op, {60, {3, 4}, nil}, :@}, {:identifier, {60, {4, 9}, nil}, :typep}, {:identifier, {60, {10, 13}, nil}, :app}, {:type_op, {60, {14, 16}, nil}, :::}, {:alias, {60, {17, 28}, nil}, :Application}, {:., {60, {28, 29}, nil}}, {:paren_identifier, {60, {29, 32}, nil}, :app}, {:"(", {60, {32, 33}, nil}}, {:")", {60, {33, 34}, nil}}, {:eol, {60, {34, 35}, 1}}, {:at_op, {61, {3, 4}, nil}, :@}, {:identifier, {61, {4, 9}, nil}, :typep}, {:identifier, {61, {10, 13}, nil}, :key}, {:type_op, {61, {14, 16}, nil}, :::}, {:alias, {61, {17, 28}, nil}, :Application}, {:., {61, {28, 29}, nil}}, {:paren_identifier, {61, {29, 32}, nil}, :key}, {:"(", {61, {32, 33}, nil}}, {:")", {61, {33, 34}, nil}}, {:eol, {61, {34, 35}, 1}}, {:at_op, {62, {3, 4}, nil}, :@}, {:identifier, {62, {4, 9}, nil}, :typep}, {:identifier, {62, {10, 15}, nil}, :value}, {:type_op, {62, {16, 18}, nil}, :::}, {:alias, {62, {19, 30}, nil}, :Application}, {:., {62, {30, 31}, nil}}, {:paren_identifier, {62, {31, 36}, nil}, :value}, {:"(", {62, {36, 37}, nil}}, {:")", {62, {37, 38}, nil}}, {:eol, {62, {38, ...}, 2}}, {:at_op, {64, {...}, ...}, :@}, {:identifier, {64, ...}, :type}, {:identifier, {...}, ...}, {:type_op, ...}, {...}, ...]}
        lib/credo/code.ex:104: Credo.Code.to_tokens/1
        lib/credo/check/consistency/space_around_operators/collector.ex:10: Credo.Check.Consistency.SpaceAroundOperators.Collector.collect_matches/2
        lib/credo/check/consistency/collector.ex:126: anonymous fn/3 in Credo.Check.Consistency.Collector.find_issues/4
        (elixir) lib/enum.ex:1306: Enum."-map/2-lists^map/1-0-"/2
        lib/credo/check/consistency/collector.ex:125: Credo.Check.Consistency.Collector.find_issues/4
        lib/credo/check/consistency/space_around_operators/collector.ex:2: Credo.Check.Consistency.SpaceAroundOperators.Collector.find_and_append_issues/4
        lib/credo/check/runner.ex:148: Credo.Check.Runner.run_check/3
        (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2

@jbodah
Copy link

jbodah commented Oct 20, 2017

I believe this is the commit in Elixir core where this changed: elixir-lang/elixir@455c2c3#diff-8e79b6aba4faa9923e1ed2defe97e290R140

Looks like there are several other regressions with Elixir 1.6 based on the tests

@rrrene
Copy link
Owner

rrrene commented Nov 4, 2017

@netflakes @pragdave @AndrewDryga @jbodah I fixed the initial problem on master, but there is a lot broken in the test suite, so I am unsure how many changes will be required once Elixir 1.6 is feature-complete.

P.S. Sorry for being late to the party, I had a work thing keeping me away 😉

@pdgonzalez872
Copy link
Contributor

pdgonzalez872 commented Apr 2, 2018

Is this still an issue? I upgraded to 0.9.0 and was able to run mix credo in a project using 1.6.

0.8.5 was having the error above though. Does upgrading solve your issue @netflakes?

@rrrene
Copy link
Owner

rrrene commented Apr 8, 2018

@pdgonzalez872 You are right, of course 👍 It should be be fixed in the latest version of Credo.

@netflakes If it is not, please feel free to re-open this issue!

@rrrene rrrene closed this as completed Apr 8, 2018
yakryder added a commit to yakryder/GMYLM-Elixir that referenced this issue Apr 24, 2019
Was running afoul of Credo issue
rrrene/credo#463 with Elixir 1.8.1 locally.

Took it as an opportunity to pin versions and get on last-month
versions of stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants