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

Elvis is failing badly when operator_spaces and line_length checks don't pass #450

Closed
harenson opened this issue Jun 14, 2017 · 1 comment
Assignees

Comments

@harenson
Copy link
Member

A bug was added in commit inaka/elvis_core@a4aeef6 and everytime operator_spaces and line_length checks don't get satisfied elvis fails badly with an error like the one below:

The issue is caused because not all the elvis_file:file()s returned by elvis_file:src/1 does contain the expected (by the previously mentioned checks) encoding parameter.

Error: '{badmatch,
                         {<<"-module(undefined_functions).\n\n-export([bad/0, bad/1]).\n\nbad() ->\n  undefined_functions:undefined_here(),\n  undefined_functions:bad(1).\n\nbad(1) ->\n  other_module:undefined_somewhere_else(),\n  bad(2);\nbad(2) ->\n  lists:foreach(\n    fun other_module:undefined_somewhere_else/1, lists:seq(1, 10)).\n">>,
                          #{commit_id =>
                             "18d656ce04845a30898e7c10f26b0f931cd95f3c",
                            content =>
                             <<"-module(undefined_functions).\n\n-export([bad/0, bad/1]).\n\nbad() ->\n  undefined_functions:undefined_here(),\n  undefined_functions:bad(1).\n\nbad(1) ->\n  other_module:undefined_somewhere_else(),\n  bad(2);\nbad(2) ->\n  lists:foreach(\n    fun other_module:undefined_somewhere_else/1, lists:seq(1, 10)).\n">>,
                            parse_tree =>
                             #{attrs =>
                                #{tokens =>
                                   [#{attrs =>
                                       #{location => {1,1},text => "-"},
                                      type => '-'},
                                    #{attrs =>
                                       #{location => {1,2},text => "module"},
                                      type => atom,value => module},
                                    #{attrs =>
                                       #{location => {1,8},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {1,9},
                                         text => "undefined_functions"},
                                      type => atom,
                                      value => undefined_functions},
                                    #{attrs =>
                                       #{location => {1,28},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {1,29},text => ".\n"},
                                      type => dot},
                                    #{attrs =>
                                       #{location => {3,1},text => "-"},
                                      type => '-'},
                                    #{attrs =>
                                       #{location => {3,2},text => "export"},
                                      type => atom,value => export},
                                    #{attrs =>
                                       #{location => {3,8},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {3,9},text => "["},
                                      type => '['},
                                    #{attrs =>
                                       #{location => {3,10},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {3,13},text => "/"},
                                      type => '/'},
                                    #{attrs =>
                                       #{location => {3,14},text => "0"},
                                      type => integer,value => 0},
                                    #{attrs =>
                                       #{location => {3,15},text => ","},
                                      type => ','},
                                    #{attrs =>
                                       #{location => {3,17},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {3,20},text => "/"},
                                      type => '/'},
                                    #{attrs =>
                                       #{location => {3,21},text => "1"},
                                      type => integer,value => 1},
                                    #{attrs =>
                                       #{location => {3,22},text => "]"},
                                      type => ']'},
                                    #{attrs =>
                                       #{location => {3,23},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {3,24},text => ".\n"},
                                      type => dot},
                                    #{attrs =>
                                       #{location => {5,1},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {5,4},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {5,5},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {5,7},text => "->"},
                                      type => '->'},
                                    #{attrs =>
                                       #{location => {6,3},
                                         text => "undefined_functions"},
                                      type => atom,
                                      value => undefined_functions},
                                    #{attrs =>
                                       #{location => {6,22},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {6,23},
                                         text => "undefined_here"},
                                      type => atom,value => undefined_here},
                                    #{attrs =>
                                       #{location => {6,37},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {6,38},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {6,39},text => ","},
                                      type => ','},
                                    #{attrs =>
                                       #{location => {7,3},
                                         text => "undefined_functions"},
                                      type => atom,
                                      value => undefined_functions},
                                    #{attrs =>
                                       #{location => {7,22},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {7,23},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {7,26},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {7,27},text => "1"},
                                      type => integer,value => 1},
                                    #{attrs =>
                                       #{location => {7,28},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {7,29},text => ".\n"},
                                      type => dot},
                                    #{attrs =>
                                       #{location => {9,1},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {9,4},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {9,5},text => "1"},
                                      type => integer,value => 1},
                                    #{attrs =>
                                       #{location => {9,6},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {9,8},text => "->"},
                                      type => '->'},
                                    #{attrs =>
                                       #{location => {10,3},
                                         text => "other_module"},
                                      type => atom,value => other_module},
                                    #{attrs =>
                                       #{location => {10,15},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {10,16},
                                         text => "undefined_somewhere_else"},
                                      type => atom,
                                      value => undefined_somewhere_else},
                                    #{attrs =>
                                       #{location => {10,40},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {10,41},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {10,42},text => ","},
                                      type => ','},
                                    #{attrs =>
                                       #{location => {11,3},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {11,6},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {11,7},text => "2"},
                                      type => integer,value => 2},
                                    #{attrs =>
                                       #{location => {11,8},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {11,9},text => ";"},
                                      type => ';'},
                                    #{attrs =>
                                       #{location => {12,1},text => "bad"},
                                      type => atom,value => bad},
                                    #{attrs =>
                                       #{location => {12,4},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {12,5},text => "2"},
                                      type => integer,value => 2},
                                    #{attrs =>
                                       #{location => {12,6},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {12,8},text => "->"},
                                      type => '->'},
                                    #{attrs =>
                                       #{location => {13,3},text => "lists"},
                                      type => atom,value => lists},
                                    #{attrs =>
                                       #{location => {13,8},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {13,9},text => "foreach"},
                                      type => atom,value => foreach},
                                    #{attrs =>
                                       #{location => {13,16},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {14,5},text => "fun"},
                                      type => 'fun'},
                                    #{attrs =>
                                       #{location => {14,9},
                                         text => "other_module"},
                                      type => atom,value => other_module},
                                    #{attrs =>
                                       #{location => {14,21},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {14,22},
                                         text => "undefined_somewhere_else"},
                                      type => atom,
                                      value => undefined_somewhere_else},
                                    #{attrs =>
                                       #{location => {14,46},text => "/"},
                                      type => '/'},
                                    #{attrs =>
                                       #{location => {14,47},text => "1"},
                                      type => integer,value => 1},
                                    #{attrs =>
                                       #{location => {14,48},text => ","},
                                      type => ','},
                                    #{attrs =>
                                       #{location => {14,50},text => "lists"},
                                      type => atom,value => lists},
                                    #{attrs =>
                                       #{location => {14,55},text => ":"},
                                      type => ':'},
                                    #{attrs =>
                                       #{location => {14,56},text => "seq"},
                                      type => atom,value => seq},
                                    #{attrs =>
                                       #{location => {14,59},text => "("},
                                      type => '('},
                                    #{attrs =>
                                       #{location => {14,60},text => "1"},
                                      type => integer,value => 1},
                                    #{attrs =>
                                       #{location => {14,61},text => ","},
                                      type => ','},
                                    #{attrs =>
                                       #{location => {14,63},text => "10"},
                                      type => integer,value => 10},
                                    #{attrs =>
                                       #{location => {14,65},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {14,66},text => ")"},
                                      type => ')'},
                                    #{attrs =>
                                       #{location => {14,67},text => ".\n"},
                                      type => dot}]},
                               content =>
                                [#{attrs =>
                                    #{location => {1,2},
                                      text => "module",
                                      value => undefined_functions},
                                   type => module},
                                 #{attrs =>
                                    #{location => {3,2},
                                      text => "export",
                                      value => [{bad,0},{bad,1}]},
                                   type => export},
                                 #{attrs =>
                                    #{arity => 0,
                                      location => {5,1},
                                      name => bad,text => "bad"},
                                   content =>
                                    [#{attrs =>
                                        #{location => {5,1},text => "bad"},
                                       content =>
                                        [#{attrs =>
                                            #{location => {6,22},text => ":"},
                                           content => [],
                                           node_attrs =>
                                            #{function =>
                                               #{attrs =>
                                                  #{location => {6,22},
                                                    text => ":"},
                                                 node_attrs =>
                                                  #{function =>
                                                     #{attrs =>
                                                        #{location => {6,23},
                                                          text =>
                                                           "undefined_here",
                                                          value =>
                                                           undefined_here},
                                                       type => atom},
                                                    module =>
                                                     #{attrs =>
                                                        #{location => {6,3},
                                                          text =>
                                                           "undefined_functions",
                                                          value =>
                                                           undefined_functions},
                                                       type => atom}},
                                                 type => remote}},
                                           type => call},
                                         #{attrs =>
                                            #{location => {7,22},text => ":"},
                                           content =>
                                            [#{attrs =>
                                                #{location => {7,27},
                                                  text => "1",value => 1},
                                               type => integer}],
                                           node_attrs =>
                                            #{function =>
                                               #{attrs =>
                                                  #{location => {7,22},
                                                    text => ":"},
                                                 node_attrs =>
                                                  #{function =>
                                                     #{attrs =>
                                                        #{location => {7,23},
                                                          text => "bad",
                                                          value => bad},
                                                       type => atom},
                                                    module =>
                                                     #{attrs =>
                                                        #{location => {7,3},
                                                          text =>
                                                           "undefined_functions",
                                                          value =>
                                                           undefined_functions},
                                                       type => atom}},
                                                 type => remote}},
                                           type => call}],
                                       node_attrs =>
                                        #{guards => [],pattern => []},
                                       type => clause}],
                                   type => function},
                                 #{attrs =>
                                    #{arity => 1,
                                      location => {9,1},
                                      name => bad,text => "bad"},
                                   content =>
                                    [#{attrs =>
                                        #{location => {9,1},text => "bad"},
                                       content =>
                                        [#{attrs =>
                                            #{location => {10,15},text => ":"},
                                           content => [],
                                           node_attrs =>
                                            #{function =>
                                               #{attrs =>
                                                  #{location => {10,15},
                                                    text => ":"},
                                                 node_attrs =>
                                                  #{function =>
                                                     #{attrs =>
                                                        #{location => {10,16},
                                                          text =>
                                                           "undefined_somewhere_else",
                                                          value =>
                                                           undefined_somewhere_else},
                                                       type => atom},
                                                    module =>
                                                     #{attrs =>
                                                        #{location => {10,3},
                                                          text =>
                                                           "other_module",
                                                          value =>
                                                           other_module},
                                                       type => atom}},
                                                 type => remote}},
                                           type => call},
                                         #{attrs =>
                                            #{location => {11,3},
                                              text => "bad"},
                                           content =>
                                            [#{attrs =>
                                                #{location => {11,7},
                                                  text => "2",value => 2},
                                               type => integer}],
                                           node_attrs =>
                                            #{function =>
                                               #{attrs =>
                                                  #{location => {11,3},
                                                    text => "bad",
                                                    value => bad},
                                                 type => atom}},
                                           type => call}],
                                       node_attrs =>
                                        #{guards => [],
                                          pattern =>
                                           [#{attrs =>
                                               #{location => {9,5},
                                                 text => "1",value => 1},
                                              type => integer}]},
                                       type => clause},
                                     #{attrs =>
                                        #{location => {12,1},text => "bad"},
                                       content =>
                                        [#{attrs =>
                                            #{location => {13,8},text => ":"},
                                           content =>
                                            [#{attrs =>
                                                #{arity =>
                                                   {integer,
                                                    [{location,{14,47}},
                                                     {text,"1"},
                                                     {location,{14,47}}],
                                                    1},
                                                  location => {14,5},
                                                  module =>
                                                   {atom,
                                                    [{location,{14,9}},
                                                     {text,"other_module"},
                                                     {location,{14,9}}],
                                                    other_module},
                                                  name =>
                                                   {atom,
                                                    [{location,{14,22}},
                                                     {text,
                                                      "undefined_somewhere_else"},
                                                     {location,{14,22}}],
                                                    undefined_somewhere_else},
                                                  text => "fun"},
                                               type => 'fun'},
                                             #{attrs =>
                                                #{location => {14,55},
                                                  text => ":"},
                                               content =>
                                                [#{attrs =>
                                                    #{location => {14,60},
                                                      text => "1",value => 1},
                                                   type => integer},
                                                 #{attrs =>
                                                    #{location => {14,63},
                                                      text => "10",
                                                      value => 10},
                                                   type => integer}],
                                               node_attrs =>
                                                #{function =>
                                                   #{attrs =>
                                                      #{location => {14,55},
                                                        text => ":"},
                                                     node_attrs =>
                                                      #{function =>
                                                         #{attrs =>
                                                            #{location =>
                                                               {14,56},
                                                              text => "seq",
                                                              value => seq},
                                                           type => atom},
                                                        module =>
                                                         #{attrs =>
                                                            #{location =>
                                                               {14,50},
                                                              text => "lists",
                                                              value => lists},
                                                           type => atom}},
                                                     type => remote}},
                                               type => call}],
                                           node_attrs =>
                                            #{function =>
                                               #{attrs =>
                                                  #{location => {13,8},
                                                    text => ":"},
                                                 node_attrs =>
                                                  #{function =>
                                                     #{attrs =>
                                                        #{location => {13,9},
                                                          text => "foreach",
                                                          value => foreach},
                                                       type => atom},
                                                    module =>
                                                     #{attrs =>
                                                        #{location => {13,3},
                                                          text => "lists",
                                                          value => lists},
                                                       type => atom}},
                                                 type => remote}},
                                           type => call}],
                                       node_attrs =>
                                        #{guards => [],
                                          pattern =>
                                           [#{attrs =>
                                               #{location => {12,5},
                                                 text => "2",value => 2},
                                              type => integer}]},
                                       type => clause}],
                                   type => function}],
                               type => root},
                            patch =>
                             <<"@@ -0,0 +1,14 @@\n+-module(undefined_functions).\n+\n+-export([bad/0, bad/1]).\n+\n+bad() ->\n+  undefined_functions:undefined_here(),\n+  undefined_functions:bad(1).\n+\n+bad(1) ->\n+  other_module:undefined_somewhere_else(),\n+  bad(2);\n+bad(2) ->\n+  lists:foreach(\n+    fun other_module:undefined_somewhere_else/1, lists:seq(1, 10)).">>,
                            path => <<"src/xref/undefined_functions.erl">>}}}' while applying rule 'line_length'.
@harenson harenson self-assigned this Jun 14, 2017
@elbrujohalcon
Copy link
Member

Fixed by inaka/elvis_core#89

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

2 participants