Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 9ad5956

Browse files
author
Juanjo Alvarez
committed
Fixed all findings by the go test checker
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 6d65ef5 commit 9ad5956

File tree

66 files changed

+39902
-39360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+39902
-39360
lines changed

driver/fixtures/fixtures_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ var Suite = &fixtures.Suite{
3535
"Name",
3636
"NoopLine",
3737
"NoopSameLine",
38-
"QualifiedIdentifier",
3938
"Str",
4039
"StringLiteral",
4140
"arg",
4241
"kwarg",
4342
"kwonly_arg",
4443
"vararg",
44+
"alias",
4545
},
4646
},
4747
}

driver/normalizer/normalizer.go

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ var Normalize = Transformers([][]Transformer{
2323
{Mappings(Normalizers...)},
2424
}...)
2525

26-
// FIXME: decorators? (annotations/tags)
2726
func funcDefMap(typ string, async bool) Mapping {
2827
return MapSemantic(typ, uast.FunctionGroup{}, MapObj(
2928
Obj{
3029
"body": Var("body"),
31-
uast.KeyToken: Var("name"),
30+
"name": Var("name"),
3231
// Arguments should be converted by the uast.Arguments normalization
3332
"args": Obj{
3433
"args": Var("arguments"),
34+
uast.KeyPos: Var("_pos"),
35+
uast.KeyType: Var("_type"),
3536
},
37+
//"decorator_list": Var("_decorators"),
38+
// XXX handle this
39+
//"returns": Var("returns"),
3640
},
3741
Obj{
3842
"Nodes": Arr(
@@ -48,7 +52,9 @@ func funcDefMap(typ string, async bool) Mapping {
4852
"Type": UASTType(uast.FunctionType{}, Obj{
4953
"Arguments": Var("arguments"),
5054
}),
51-
"Body": Var("body"),
55+
"Body": UASTType(uast.Block{}, Obj{
56+
"Statements": Var("body"),
57+
}),
5258
}),
5359
}),
5460
),
@@ -92,17 +98,43 @@ var Normalizers = []Mapping{
9298
Obj{"Name": Var("name")},
9399
)),
94100

101+
MapSemantic("Attribute", uast.Identifier{}, MapObj(
102+
Obj{"attr": Var("name")},
103+
Obj{"Name": Var("name")},
104+
)),
105+
106+
MapSemantic("alias", uast.Alias{}, MapObj(
107+
Obj{
108+
"name": Var("name"),
109+
"asname": Var("aliased"),
110+
},
111+
Obj{
112+
"Name": UASTType(uast.Identifier{}, Obj{
113+
"Name": Var("name"),
114+
}),
115+
"Node": UASTType(uast.Identifier{}, Obj{
116+
"Name": Var("aliased"),
117+
}),
118+
},
119+
)),
120+
95121
MapSemantic("Name", uast.Identifier{}, MapObj(
96122
Obj{"attr": Var("name")},
97123
Obj{"Name": Var("name")},
98124
)),
99125

100126
// FIXME: check that the identifiers are in the right order
101127
// FIXME: check that those are uast:Identifiers
102-
MapSemantic("QualifiedIdentifier", uast.QualifiedIdentifier{}, MapObj(
103-
Obj{"identifiers": Var("identifiers")},
104-
Obj{"Names": Var("identifiers")},
105-
)),
128+
//MapSemantic("QualifiedIdentifier", uast.QualifiedIdentifier{}, MapObj(
129+
// Obj{"identifiers": Var("identifiers")},
130+
// Obj{"Names": Var("identifiers")},
131+
//)),
132+
//MapSemantic("QualifiedIdentifier", uast.QualifiedIdentifier{}, MapObj(
133+
// Obj{"identifiers": Each("ids", Var("ident"))},
134+
// Obj{"Names": Each("ids", UASTType(uast.Identifier{}, Obj{
135+
// "Name": Var("ident"),
136+
// }))},
137+
//)),
106138

107139
MapSemantic("NoopLine", uast.Comment{}, MapObj(
108140
Obj{"noop_line": CommentText([2]string{}, "comm")},
@@ -178,27 +210,29 @@ var Normalizers = []Mapping{
178210
funcDefMap("FunctionDef", false),
179211
funcDefMap("AsyncFunctionDef", true),
180212

181-
// FIXME: check that those are uast:Identifiers too
182-
MapSemantic("Import", uast.RuntimeImport{}, MapObj(
213+
214+
// FIXME: what to do with levels? convert to ../../... in Path?
215+
// FIXME: "import * from x": check the * and set "All" to true
216+
MapSemantic("ImportFrom", uast.RuntimeImport{}, MapObj(
183217
Obj{
184-
"names": Var("names"),
218+
"names": Var("names"),
219+
"module": Var("module"),
185220
},
186221
Obj{
187222
"Names": Var("names"),
223+
"Path": UASTType(uast.String{}, Obj{
224+
"Value": Var("module"),
225+
"Format": String(""),
226+
}),
188227
},
189228
)),
190229

191-
// FIXME: what to do with levels? convert to ../../... in Path?
192-
// FIXME: Import rename (import x as y)
193-
// FIXME: "import * from x": check the * and set "All" to true
194-
MapSemantic("ImportFrom", uast.RuntimeImport{}, MapObj(
230+
MapSemantic("Import", uast.RuntimeImport{}, MapObj(
195231
Obj{
196-
"names": Var("names"),
197-
"module": Var("module"),
232+
"names": Var("names"),
198233
},
199234
Obj{
200235
"Names": Var("names"),
201-
"Path": Var("module"),
202236
},
203237
)),
204238
}

fixtures/annotations.py.sem.uast

Lines changed: 90 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@
102102
},
103103
value: ~,
104104
},
105-
{ '@type': "FunctionDef",
106-
'@token': "somefunc",
107-
'@role': [Declaration, Function, Identifier, Name],
105+
{ '@type': "uast:FunctionGroup",
108106
'@pos': { '@type': "uast:Positions",
109107
start: { '@type': "uast:Position",
110108
offset: 24,
@@ -117,113 +115,103 @@
117115
col: 12,
118116
},
119117
},
120-
args: { '@type': "arguments",
121-
'@role': [Argument, Declaration, Function, Incomplete],
122-
'@pos': { '@type': "uast:Positions",
118+
Nodes: [
119+
{
120+
async: false,
123121
},
124-
args: [
125-
{ '@type': "uast:Argument",
126-
'@pos': { '@type': "uast:Positions",
127-
start: { '@type': "uast:Position",
128-
offset: 33,
129-
line: 3,
130-
col: 14,
131-
},
132-
end: { '@type': "uast:Position",
133-
offset: 33,
134-
line: 3,
135-
col: 14,
136-
},
137-
},
138-
Init: ~,
139-
MapVariadic: false,
140-
Name: { '@type': "uast:Identifier",
141-
Name: "a",
142-
},
143-
Receiver: false,
144-
Type: ~,
145-
Variadic: false,
122+
{ '@type': "uast:Alias",
123+
Name: { '@type': "uast:Identifier",
124+
Name: "somefunc",
146125
},
147-
{ '@type': "uast:Argument",
148-
'@pos': { '@type': "uast:Positions",
149-
start: { '@type': "uast:Position",
150-
offset: 41,
151-
line: 3,
152-
col: 22,
153-
},
154-
end: { '@type': "uast:Position",
155-
offset: 41,
156-
line: 3,
157-
col: 22,
158-
},
159-
},
160-
Init: ~,
161-
MapVariadic: false,
162-
Name: { '@type': "uast:Identifier",
163-
Name: "b",
164-
},
165-
Receiver: false,
166-
Type: ~,
167-
Variadic: false,
168-
},
169-
],
170-
},
171-
body: { '@type': "FunctionDef.body",
172-
'@role': [Body, Declaration, Function],
173-
'body_stmts': [
174-
{ '@type': "Return",
175-
'@token': "return",
176-
'@role': [Return, Statement],
177-
'@pos': { '@type': "uast:Positions",
178-
start: { '@type': "uast:Position",
179-
offset: 63,
180-
line: 4,
181-
col: 5,
182-
},
183-
end: { '@type': "uast:Position",
184-
offset: 68,
185-
line: 4,
186-
col: 10,
187-
},
126+
Node: { '@type': "uast:Function",
127+
Body: { '@type': "uast:Block",
128+
Statements: [
129+
{ '@type': "Return",
130+
'@token': "return",
131+
'@role': [Return, Statement],
132+
'@pos': { '@type': "uast:Positions",
133+
start: { '@type': "uast:Position",
134+
offset: 63,
135+
line: 4,
136+
col: 5,
137+
},
138+
end: { '@type': "uast:Position",
139+
offset: 68,
140+
line: 4,
141+
col: 10,
142+
},
143+
},
144+
value: { '@type': "Num",
145+
'@token': 0,
146+
'@role': [Expression, Literal, Number, Primitive],
147+
'@pos': { '@type': "uast:Positions",
148+
start: { '@type': "uast:Position",
149+
offset: 70,
150+
line: 4,
151+
col: 12,
152+
},
153+
end: { '@type': "uast:Position",
154+
offset: 72,
155+
line: 4,
156+
col: 14,
157+
},
158+
},
159+
},
160+
},
161+
],
188162
},
189-
value: { '@type': "Num",
190-
'@token': 0,
191-
'@role': [Expression, Literal, Number, Primitive],
192-
'@pos': { '@type': "uast:Positions",
193-
start: { '@type': "uast:Position",
194-
offset: 70,
195-
line: 4,
196-
col: 12,
163+
Type: { '@type': "uast:FunctionType",
164+
Arguments: [
165+
{ '@type': "uast:Argument",
166+
'@pos': { '@type': "uast:Positions",
167+
start: { '@type': "uast:Position",
168+
offset: 33,
169+
line: 3,
170+
col: 14,
171+
},
172+
end: { '@type': "uast:Position",
173+
offset: 33,
174+
line: 3,
175+
col: 14,
176+
},
177+
},
178+
Init: ~,
179+
MapVariadic: false,
180+
Name: { '@type': "uast:Identifier",
181+
Name: "a",
182+
},
183+
Receiver: false,
184+
Type: ~,
185+
Variadic: false,
197186
},
198-
end: { '@type': "uast:Position",
199-
offset: 72,
200-
line: 4,
201-
col: 14,
187+
{ '@type': "uast:Argument",
188+
'@pos': { '@type': "uast:Positions",
189+
start: { '@type': "uast:Position",
190+
offset: 41,
191+
line: 3,
192+
col: 22,
193+
},
194+
end: { '@type': "uast:Position",
195+
offset: 41,
196+
line: 3,
197+
col: 22,
198+
},
199+
},
200+
Init: ~,
201+
MapVariadic: false,
202+
Name: { '@type': "uast:Identifier",
203+
Name: "b",
204+
},
205+
Receiver: false,
206+
Type: ~,
207+
Variadic: false,
202208
},
203-
},
209+
],
210+
Returns: ~,
204211
},
205212
},
206-
],
207-
},
208-
'decorator_list': { '@type': "FunctionDef.decorators",
209-
'@role': [Declaration, Function, Incomplete],
210-
decorators: [],
211-
},
212-
returns: { '@type': "uast:Identifier",
213-
'@pos': { '@type': "uast:Positions",
214-
start: { '@type': "uast:Position",
215-
offset: 52,
216-
line: 3,
217-
col: 33,
218-
},
219-
end: { '@type': "uast:Position",
220-
offset: 56,
221-
line: 3,
222-
col: 37,
223-
},
224213
},
225-
Name: "float",
226-
},
214+
],
227215
},
228216
],
229217
}

0 commit comments

Comments
 (0)