@@ -496,10 +496,7 @@ checkWrongArithmeticAssignment params (T_SimpleCommand id [T_Assignment _ _ _ _
496
496
" Use $((..)) for arithmetics, e.g. i=$((i " ++ op ++ " 2))"
497
497
where
498
498
regex = mkRegex " ^([_a-zA-Z][_a-zA-Z0-9]*)([+*-]).+$"
499
- references = foldl (flip ($) ) S. empty (map insertRef $ variableFlow params)
500
- insertRef (Assignment (_, _, name, _)) =
501
- S. insert name
502
- insertRef _ = Prelude. id
499
+ references = S. fromList [name | Assignment (_, _, name, _) <- variableFlow params]
503
500
504
501
getNormalString (T_NormalWord _ words ) = do
505
502
parts <- mapM getLiterals words
@@ -2380,15 +2377,9 @@ prop_checkUnused51 = verifyTree checkUnusedAssignments "x[y[z=1]]=1; echo ${x[@]
2380
2377
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
2381
2378
where
2382
2379
flow = variableFlow params
2383
- references = foldl (flip ($) ) defaultMap (map insertRef flow)
2384
- insertRef (Reference (base, token, name)) =
2385
- Map. insert (stripSuffix name) ()
2386
- insertRef _ = id
2380
+ references = Map. union (Map. fromList [(stripSuffix name, () ) | Reference (base, token, name) <- flow]) defaultMap
2387
2381
2388
- assignments = foldl (flip ($) ) Map. empty (map insertAssignment flow)
2389
- insertAssignment (Assignment (_, token, name, _)) | isVariableName name =
2390
- Map. insert name token
2391
- insertAssignment _ = id
2382
+ assignments = Map. fromList [(name, token) | Assignment (_, token, name, _) <- flow, isVariableName name]
2392
2383
2393
2384
unused = Map. assocs $ Map. difference assignments references
2394
2385
@@ -3971,10 +3962,7 @@ checkTranslatedStringVariable params (T_DollarDoubleQuoted id [T_Literal _ s])
3971
3962
&& S. member s assignments
3972
3963
= warnWithFix id 2256 " This translated string is the name of a variable. Flip leading $ and \" if this should be a quoted substitution." (fix id )
3973
3964
where
3974
- assignments = foldl (flip ($) ) S. empty (map insertAssignment $ variableFlow params)
3975
- insertAssignment (Assignment (_, _, name, _)) | isVariableName name =
3976
- S. insert name
3977
- insertAssignment _ = Prelude. id
3965
+ assignments = S. fromList [name | Assignment (_, _, name, _) <- variableFlow params, isVariableName name]
3978
3966
fix id = fixWith [replaceStart id params 2 " \" $" ]
3979
3967
checkTranslatedStringVariable _ _ = return ()
3980
3968
0 commit comments