Skip to content

Commit 4e0a8d9

Browse files
committed
enable wsl linter
1 parent 88fde0f commit 4e0a8d9

Some content is hidden

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

50 files changed

+405
-129
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
run:
2+
skip-files:
3+
- ".*_gen\\.go$"
4+
linters:
5+
enable:
6+
- wsl

bridge.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (b *BridgeData) Channels() (list []*Key) {
8888
for _, id := range b.ChannelIDs {
8989
list = append(list, b.Key.New(ChannelKey, id))
9090
}
91+
9192
return
9293
}
9394

@@ -125,9 +126,11 @@ func (bh *BridgeHandle) Exec() error {
125126
if bh.exec != nil {
126127
err := bh.exec(bh)
127128
bh.exec = nil
129+
128130
return err
129131
}
130132
}
133+
131134
return nil
132135
}
133136

@@ -193,5 +196,6 @@ func (bh *BridgeHandle) Subscribe(n ...string) Subscription {
193196
if bh == nil {
194197
return nil
195198
}
199+
196200
return bh.b.Subscribe(bh.key, n...)
197201
}

bus.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func Once(ctx context.Context, bus Bus, key *Key, eTypes ...string) <-chan Event
4848
close(ret)
4949
s.Cancel()
5050
}()
51+
5152
return ret
5253
}
5354

@@ -65,26 +66,30 @@ type NullSubscription struct {
6566
mu sync.RWMutex
6667
}
6768

69+
// Events implements the Subscription interface
6870
func (n *NullSubscription) Events() <-chan Event {
6971
if n.ch == nil {
7072
n.mu.Lock()
7173
n.closed = false
7274
n.ch = make(chan Event)
7375
n.mu.Unlock()
7476
}
77+
7578
return n.ch
7679
}
7780

81+
// Cancel implements the Subscription interface
7882
func (n *NullSubscription) Cancel() {
7983
if n.closed {
8084
return
8185
}
8286

8387
n.mu.Lock()
88+
8489
n.closed = true
8590
if n.ch != nil {
8691
close(n.ch)
8792
}
88-
n.mu.Unlock()
8993

94+
n.mu.Unlock()
9095
}

bus_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package ari
33
import "testing"
44

55
func TestNullSubscription(t *testing.T) {
6-
76
sub := NewNullSubscription()
87

98
select {
@@ -28,5 +27,4 @@ func TestNullSubscription(t *testing.T) {
2827
default:
2928
t.Error("NullSubscription failed to close")
3029
}
31-
3230
}

channel.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ func (d *ChannelData) MarshalJSON() ([]byte, error) {
160160
// UnmarshalJSON decodes ChannelData from JSON
161161
func (d *ChannelData) UnmarshalJSON(data []byte) error {
162162
in := new(channelDataJSON)
163-
err := json.Unmarshal(data, in)
164-
if err != nil {
163+
164+
if err := json.Unmarshal(data, in); err != nil {
165165
return err
166166
}
167167

@@ -182,6 +182,7 @@ func (d *ChannelData) UnmarshalJSON(data []byte) error {
182182
Dialplan: in.Dialplan,
183183
ChannelVars: in.ChannelVars,
184184
}
185+
185186
return nil
186187
}
187188

@@ -266,6 +267,7 @@ func (ch *ChannelHandle) Exec() (err error) {
266267
ch.exec = nil
267268
}
268269
}
270+
269271
return err
270272
}
271273

@@ -340,6 +342,7 @@ func (ch *ChannelHandle) IsAnswered() (bool, error) {
340342
if err != nil {
341343
return false, errors.Wrap(err, "Failed to get updated channel")
342344
}
345+
343346
return strings.ToLower(updated.State) == "up", nil
344347
}
345348

@@ -437,6 +440,7 @@ func (ch *ChannelHandle) Originate(req OriginateRequest) (*ChannelHandle, error)
437440
if req.Originator == "" {
438441
req.Originator = ch.ID()
439442
}
443+
440444
return ch.c.Originate(ch.key, req)
441445
}
442446

@@ -503,6 +507,7 @@ func (ch *ChannelHandle) Subscribe(n ...string) Subscription {
503507
if ch == nil {
504508
return nil
505509
}
510+
506511
return ch.c.Subscribe(ch.key, n...)
507512
}
508513

client/native/application.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ func (a *Application) Get(key *ari.Key) *ari.ApplicationHandle {
1919

2020
// List returns the list of applications managed by asterisk
2121
func (a *Application) List(filter *ari.Key) (ax []*ari.Key, err error) {
22-
2322
if filter == nil {
2423
filter = ari.NewKey(ari.ApplicationKey, "")
2524
}
2625

27-
var apps = []struct {
26+
apps := []struct {
2827
Name string `json:"name"`
2928
}{}
3029

@@ -38,6 +37,7 @@ func (a *Application) List(filter *ari.Key) (ax []*ari.Key, err error) {
3837
}
3938

4039
err = errors.Wrap(err, "Error listing applications")
40+
4141
return
4242
}
4343

@@ -48,12 +48,13 @@ func (a *Application) Data(key *ari.Key) (*ari.ApplicationData, error) {
4848
return nil, errors.New("application key not supplied")
4949
}
5050

51-
var data = new(ari.ApplicationData)
51+
data := new(ari.ApplicationData)
5252
if err := a.client.get("/applications/"+key.ID, data); err != nil {
5353
return nil, dataGetError(err, "application", "%v", key.ID)
5454
}
5555

5656
data.Key = a.client.stamp(key)
57+
5758
return data, nil
5859
}
5960

@@ -65,7 +66,9 @@ func (a *Application) Subscribe(key *ari.Key, eventSource string) error {
6566
}{
6667
EventSource: eventSource,
6768
}
69+
6870
err := a.client.post("/applications/"+key.ID+"/subscription", nil, &req)
71+
6972
return errors.Wrapf(err, "Error subscribing application '%v' for event source '%v'", key.ID, eventSource)
7073
}
7174

@@ -75,5 +78,6 @@ func (a *Application) Subscribe(key *ari.Key, eventSource string) error {
7578
func (a *Application) Unsubscribe(key *ari.Key, eventSource string) error {
7679
name := key.ID
7780
err := a.client.del("/applications/"+name+"/subscription", nil, fmt.Sprintf("eventSource=%s", eventSource))
81+
7882
return errors.Wrapf(err, "Error unsubscribing application '%v' for event source '%v'", name, eventSource)
7983
}

client/native/asterisk.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func (a *Asterisk) Config() ari.Config {
3939
// Equivalent to GET /asterisk/info
4040
func (a *Asterisk) Info(key *ari.Key) (*ari.AsteriskInfo, error) {
4141
var m ari.AsteriskInfo
42+
4243
return &m, errors.Wrap(
4344
a.client.get("/asterisk/info", &m),
4445
"failed to get asterisk info",
@@ -61,10 +62,12 @@ func (a *AsteriskVariables) Get(key *ari.Key) (string, error) {
6162
var m struct {
6263
Value string `json:"value"`
6364
}
65+
6466
err := a.client.get(fmt.Sprintf("/asterisk/variable?variable=%s", key.ID), &m)
6567
if err != nil {
6668
return "", errors.Wrapf(err, "Error getting asterisk variable '%v'", key.ID)
6769
}
70+
6871
return m.Value, nil
6972
}
7073

client/native/bridge.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func (b *Bridge) Create(key *ari.Key, t string, name string) (bh *ari.BridgeHand
1919
if err != nil {
2020
return nil, err
2121
}
22+
2223
return bh, bh.Exec()
2324
}
2425

@@ -51,18 +52,19 @@ func (b *Bridge) Get(key *ari.Key) *ari.BridgeHandle {
5152
// List lists the current bridges and returns a list of lazy handles
5253
func (b *Bridge) List(filter *ari.Key) (bx []*ari.Key, err error) {
5354
// native client ignores filter
54-
5555
bridges := []struct {
5656
ID string `json:"id"`
5757
}{}
5858

5959
err = b.client.get("/bridges", &bridges)
60+
6061
for _, i := range bridges {
6162
k := b.client.stamp(ari.NewKey(ari.BridgeKey, i.ID))
6263
if filter.Match(k) {
6364
bx = append(bx, k)
6465
}
6566
}
67+
6668
return
6769
}
6870

@@ -106,6 +108,7 @@ func (b *Bridge) AddChannelWithOptions(key *ari.Key, channelID string, options *
106108
Mute: options.Mute,
107109
Role: options.Role,
108110
}
111+
109112
return b.client.post("/bridges/"+key.ID+"/addChannel", nil, &req)
110113
}
111114

@@ -122,6 +125,7 @@ func (b *Bridge) RemoveChannel(key *ari.Key, channelID string) (err error) {
122125

123126
// pass request
124127
err = b.client.post("/bridges/"+id+"/removeChannel", nil, &req)
128+
125129
return
126130
}
127131

@@ -140,6 +144,7 @@ func (b *Bridge) MOH(key *ari.Key, class string) error {
140144
}{
141145
Class: class,
142146
}
147+
143148
return b.client.post("/bridges/"+key.ID+"/moh", nil, &req)
144149
}
145150

@@ -154,10 +159,12 @@ func (b *Bridge) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.Pl
154159
if playbackID == "" {
155160
playbackID = rid.New(rid.Playback)
156161
}
162+
157163
h, err := b.StagePlay(key, playbackID, mediaURI)
158164
if err != nil {
159165
return nil, err
160166
}
167+
161168
return h, h.Exec()
162169
}
163170

@@ -187,6 +194,7 @@ func (b *Bridge) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (
187194
if err != nil {
188195
return nil, err
189196
}
197+
190198
return h, h.Exec()
191199
}
192200

0 commit comments

Comments
 (0)