Skip to content

Commit

Permalink
fix unused method receiver (#382)
Browse files Browse the repository at this point in the history
* refactor: fix unused method receiver

Methods with unused receivers can be a symptom of unfinished refactoring or a bug. To keep 
the same method signature, omit the receiver name or '_' as it is unused.

* style: Format code with gofumpt

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Divanshu Chauhan <[email protected]>
  • Loading branch information
deepsource-autofix[bot] and Divkix authored Jun 11, 2023
1 parent aac7021 commit d1f0081
Show file tree
Hide file tree
Showing 23 changed files with 112 additions and 112 deletions.
4 changes: 2 additions & 2 deletions alita/modules/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (m adminModuleStruct) promote(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.EndGroups
}

func (m adminModuleStruct) getinvitelink(b *gotgbot.Bot, ctx *ext.Context) error {
func (adminModuleStruct) getinvitelink(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
msg := ctx.EffectiveMessage

Expand Down Expand Up @@ -572,7 +572,7 @@ func (m adminModuleStruct) anonAdmin(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.EndGroups
}

func (m adminModuleStruct) adminCache(b *gotgbot.Bot, ctx *ext.Context) error {
func (adminModuleStruct) adminCache(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
msg := ctx.EffectiveMessage
user := ctx.EffectiveSender.User
Expand Down
2 changes: 1 addition & 1 deletion alita/modules/antiflood.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var antifloodModule = antifloodModuleStruct{
floodMap: sync.Map{},
}

func (m *antifloodModuleStruct) updateFlood(chatId, userId, msgId int64) (returnVar bool, floodCrc floodControl) {
func (*antifloodModuleStruct) updateFlood(chatId, userId, msgId int64) (returnVar bool, floodCrc floodControl) {
floodSrc := db.GetFlood(chatId)

if floodSrc.Limit != 0 {
Expand Down
4 changes: 2 additions & 2 deletions alita/modules/antispam.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type antiSpamLevel struct {
Spammed bool
}

func (m antispamModuleStruct) checkSpammed(chatId int64, levels []antiSpamLevel) bool {
func (antispamModuleStruct) checkSpammed(chatId int64, levels []antiSpamLevel) bool {
_asInfo, ok := antispamModule.antiSpam[chatId]
if !ok {
// Assign a new AntiSpamInfo to the chatId because not found
Expand Down Expand Up @@ -65,7 +65,7 @@ func (m antispamModuleStruct) checkSpammed(chatId int64, levels []antiSpamLevel)
return spammed
}

func (m antispamModuleStruct) spamCheck(chatId int64) bool {
func (antispamModuleStruct) spamCheck(chatId int64) bool {
// if sql.IsUserSudo(chatId) {
// return false
// }
Expand Down
8 changes: 4 additions & 4 deletions alita/modules/bans.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ func (m bansModuleStruct) unban(b *gotgbot.Bot, ctx *ext.Context) error {
/* Used to Restrict members from a chat
Shows an inline keyboard menu which shows options to kick, ban and mute */

func (m bansModuleStruct) restrict(b *gotgbot.Bot, ctx *ext.Context) error {
func (bansModuleStruct) restrict(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
user := ctx.EffectiveSender.User
msg := ctx.EffectiveMessage
Expand Down Expand Up @@ -775,7 +775,7 @@ func (m bansModuleStruct) restrict(b *gotgbot.Bot, ctx *ext.Context) error {
}

// Handles the queries fore restrict command
func (m bansModuleStruct) restrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
func (bansModuleStruct) restrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
query := ctx.Update.CallbackQuery
chat := ctx.EffectiveChat
user := ctx.EffectiveSender.User
Expand Down Expand Up @@ -876,7 +876,7 @@ func (m bansModuleStruct) restrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context
/* Used to Unrestrict members from a chat
Shows an inline keyboard menu which shows options to unban and unmute */

func (m bansModuleStruct) unrestrict(b *gotgbot.Bot, ctx *ext.Context) error {
func (bansModuleStruct) unrestrict(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
user := ctx.EffectiveSender.User
msg := ctx.EffectiveMessage
Expand Down Expand Up @@ -954,7 +954,7 @@ func (m bansModuleStruct) unrestrict(b *gotgbot.Bot, ctx *ext.Context) error {
}

// Handles queries for unrestrict command
func (m bansModuleStruct) unrestrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
func (bansModuleStruct) unrestrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
query := ctx.Update.CallbackQuery
chat := ctx.EffectiveChat
user := ctx.EffectiveSender.User
Expand Down
4 changes: 2 additions & 2 deletions alita/modules/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ func (m connectionsModuleStruct) reconnect(b *gotgbot.Bot, ctx *ext.Context) err
return ext.EndGroups
}

func (m connectionsModuleStruct) adminCmdConnString() string {
func (connectionsModuleStruct) adminCmdConnString() string {
return "\n - /" + strings.Join(misc.AdminCmds, "\n - /")
}

func (m connectionsModuleStruct) userCmdConnString() string {
func (connectionsModuleStruct) userCmdConnString() string {
return "\n - /" + strings.Join(misc.UserCmds, "\n - /")
}

Expand Down
4 changes: 2 additions & 2 deletions alita/modules/dbclean.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
log "github.com/sirupsen/logrus"
)

func (m devsModuleStruct) dbClean(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) dbClean(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
memStatus := db.GetTeamMemInfo(user.Id)

Expand Down Expand Up @@ -45,7 +45,7 @@ func (m devsModuleStruct) dbClean(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.EndGroups
}

func (m devsModuleStruct) buttonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) buttonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
query := ctx.Update.CallbackQuery
user := ctx.EffectiveSender.User
msg := query.Message
Expand Down
18 changes: 9 additions & 9 deletions alita/modules/devs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var devsModule = devsModuleStruct{modname: "Dev"}
// for general purposes for strings in functions below
var txt string

func (m devsModuleStruct) chatInfo(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) chatInfo(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
memStatus := db.GetTeamMemInfo(user.Id)

Expand Down Expand Up @@ -67,7 +67,7 @@ func (m devsModuleStruct) chatInfo(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.ContinueGroups
}

func (m devsModuleStruct) chatList(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) chatList(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
memStatus := db.GetTeamMemInfo(user.Id)

Expand Down Expand Up @@ -141,7 +141,7 @@ func (m devsModuleStruct) chatList(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.EndGroups
}

func (m devsModuleStruct) leaveChat(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) leaveChat(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
memStatus := db.GetTeamMemInfo(user.Id)

Expand Down Expand Up @@ -174,7 +174,7 @@ func (m devsModuleStruct) leaveChat(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by OWNER
*/
func (m devsModuleStruct) addSudo(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) addSudo(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
if user.Id != config.OwnerId {
return ext.ContinueGroups
Expand Down Expand Up @@ -214,7 +214,7 @@ func (m devsModuleStruct) addSudo(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by OWNER
*/
func (m devsModuleStruct) addDev(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) addDev(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
if user.Id != config.OwnerId {
return ext.ContinueGroups
Expand Down Expand Up @@ -254,7 +254,7 @@ func (m devsModuleStruct) addDev(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by OWNER
*/
func (m devsModuleStruct) remSudo(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) remSudo(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
if user.Id != config.OwnerId {
return ext.ContinueGroups
Expand Down Expand Up @@ -294,7 +294,7 @@ func (m devsModuleStruct) remSudo(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by OWNER
*/
func (m devsModuleStruct) remDev(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) remDev(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
if user.Id != config.OwnerId {
return ext.ContinueGroups
Expand Down Expand Up @@ -334,7 +334,7 @@ func (m devsModuleStruct) remDev(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by existing team members
*/
func (m devsModuleStruct) listTeam(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) listTeam(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User

teamUsers := db.GetTeamMembers()
Expand Down Expand Up @@ -401,7 +401,7 @@ func (m devsModuleStruct) listTeam(b *gotgbot.Bot, ctx *ext.Context) error {
Can only be used by OWNER
*/
func (m devsModuleStruct) getStats(b *gotgbot.Bot, ctx *ext.Context) error {
func (devsModuleStruct) getStats(b *gotgbot.Bot, ctx *ext.Context) error {
user := ctx.EffectiveSender.User
memStatus := db.GetTeamMemInfo(user.Id)

Expand Down
10 changes: 5 additions & 5 deletions alita/modules/disabling.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var disablingModule = disablingModuleStruct{modname: "Disabling"}
Only Admin can use this command to disable usage of a command in the chat
*/
func (m disablingModuleStruct) disable(b *gotgbot.Bot, ctx *ext.Context) error {
func (disablingModuleStruct) disable(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
// connection status
connectedChat := helpers.IsUserConnected(b, ctx, true, true)
Expand Down Expand Up @@ -87,7 +87,7 @@ func (m disablingModuleStruct) disable(b *gotgbot.Bot, ctx *ext.Context) error {
Anyone can use this command to check the disableable commands
*/
func (m disablingModuleStruct) disableable(b *gotgbot.Bot, ctx *ext.Context) error {
func (disablingModuleStruct) disableable(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage

text := "The following commands can be disabled:"
Expand All @@ -111,7 +111,7 @@ func (m disablingModuleStruct) disableable(b *gotgbot.Bot, ctx *ext.Context) err
Any user in can use this command to check the disabled commands in the current chat.
*/
func (m disablingModuleStruct) disabled(b *gotgbot.Bot, ctx *ext.Context) error {
func (disablingModuleStruct) disabled(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
// if command is disabled, return
if chat_status.CheckDisabledCmd(b, msg, "adminlist") {
Expand Down Expand Up @@ -171,7 +171,7 @@ func (m disablingModuleStruct) disabled(b *gotgbot.Bot, ctx *ext.Context) error
Only admins can use this command to either choose to delete the disabled command
or not to. If no argument is given, the current chat setting is returned
*/
func (m disablingModuleStruct) disabledel(b *gotgbot.Bot, ctx *ext.Context) error {
func (disablingModuleStruct) disabledel(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
// connection status
connectedChat := helpers.IsUserConnected(b, ctx, true, true)
Expand Down Expand Up @@ -220,7 +220,7 @@ func (m disablingModuleStruct) disabledel(b *gotgbot.Bot, ctx *ext.Context) erro
Only Admin can use this command to re-enable usage of a disabled command in the chat
*/
func (m disablingModuleStruct) enable(b *gotgbot.Bot, ctx *ext.Context) error {
func (disablingModuleStruct) enable(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
// connection status
connectedChat := helpers.IsUserConnected(b, ctx, true, true)
Expand Down
10 changes: 5 additions & 5 deletions alita/modules/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (m filtersModuleStruct) addFilter(b *gotgbot.Bot, ctx *ext.Context) error {
Only admin can remove filters in the chat
*/
func (m filtersModuleStruct) rmFilter(b *gotgbot.Bot, ctx *ext.Context) error {
func (filtersModuleStruct) rmFilter(b *gotgbot.Bot, ctx *ext.Context) error {
// connection status
connectedChat := helpers.IsUserConnected(b, ctx, true, false)
if connectedChat == nil {
Expand Down Expand Up @@ -216,7 +216,7 @@ func (m filtersModuleStruct) rmFilter(b *gotgbot.Bot, ctx *ext.Context) error {
Any user can view users in a chat
*/
func (m filtersModuleStruct) filtersList(b *gotgbot.Bot, ctx *ext.Context) error {
func (filtersModuleStruct) filtersList(b *gotgbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
// if command is disabled, return
if chat_status.CheckDisabledCmd(b, msg, "filters") {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (m filtersModuleStruct) filtersList(b *gotgbot.Bot, ctx *ext.Context) error
Only owner can remove all filters from the chat
*/
func (m filtersModuleStruct) rmAllFilters(b *gotgbot.Bot, ctx *ext.Context) error {
func (filtersModuleStruct) rmAllFilters(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
user := ctx.EffectiveSender.User
msg := ctx.EffectiveMessage
Expand Down Expand Up @@ -311,7 +311,7 @@ func (m filtersModuleStruct) rmAllFilters(b *gotgbot.Bot, ctx *ext.Context) erro
}

// CallbackQuery handler for rmAllFilters
func (m filtersModuleStruct) buttonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
func (filtersModuleStruct) buttonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
query := ctx.Update.CallbackQuery
user := query.From
chat := ctx.EffectiveChat
Expand Down Expand Up @@ -408,7 +408,7 @@ func (m filtersModuleStruct) filterOverWriteHandler(b *gotgbot.Bot, ctx *ext.Con
Replies with appropriate data to the filter.
*/
func (m filtersModuleStruct) filtersWatcher(b *gotgbot.Bot, ctx *ext.Context) error {
func (filtersModuleStruct) filtersWatcher(b *gotgbot.Bot, ctx *ext.Context) error {
chat := ctx.EffectiveChat
msg := ctx.EffectiveMessage
user := ctx.EffectiveSender.User
Expand Down
4 changes: 2 additions & 2 deletions alita/modules/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (m formattingModuleStruct) markdownHelp(b *gotgbot.Bot, ctx *ext.Context) e
return ext.EndGroups
}

func (m formattingModuleStruct) genFormattingKb() [][]gotgbot.InlineKeyboardButton {
func (formattingModuleStruct) genFormattingKb() [][]gotgbot.InlineKeyboardButton {
fxt := "formatting.%s"

keyboard := [][]gotgbot.InlineKeyboardButton{
Expand All @@ -110,7 +110,7 @@ func (m formattingModuleStruct) genFormattingKb() [][]gotgbot.InlineKeyboardButt
return keyboard
}

func (m formattingModuleStruct) getMarkdownHelp(module string) string {
func (formattingModuleStruct) getMarkdownHelp(module string) string {
var helpTxt string
tr := i18n.I18n{LangCode: "en"}
if module == "md_formatting" {
Expand Down
Loading

0 comments on commit d1f0081

Please sign in to comment.