-
Notifications
You must be signed in to change notification settings - Fork 12
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
linter #18
linter #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package app | |
|
||
import ( | ||
"github.com/oklog/run" | ||
"github.com/sirupsen/logrus" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not use direct Note that not all parts of code uses it now, but it will in future. |
||
) | ||
|
||
type AppGroup struct { | ||
|
@@ -13,7 +14,10 @@ func NewAppGroup() *AppGroup { | |
} | ||
|
||
func (a *AppGroup) Run() { | ||
a.runGroup.Run() | ||
err := a.runGroup.Run() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to add logging here and in other places just for suppressing linter messages. Logging is a part of public application output. All these new log messages for errors is not useful information about how app runs. Let's return |
||
if err != nil { | ||
logrus.Errorf("failed to run appGroup: %s", err) | ||
} | ||
} | ||
|
||
// Add (function) to the application group. Each actor must be pre-emptable by an | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,62 @@ const ( | |
|
||
// List of SQL queries string | ||
const ( | ||
sLoadModulesSQL string = "SELECT m.`id`, IFNULL(g.`hash`, '') AS `group_id`, IFNULL(p.`hash`, '') AS `policy_id`, m.`info`, m.`last_update`, m.`last_module_update`, m.`state`, m.`template` FROM `modules` m LEFT JOIN (SELECT * FROM `policies` UNION SELECT 0, '', '{}', NOW(), NOW(), NULL) p ON m.`policy_id` = p.`id` AND p.deleted_at IS NULL LEFT JOIN `groups_to_policies` gp ON gp.`policy_id` = p.`id` LEFT JOIN (SELECT * FROM `groups` UNION SELECT 0, '', '{}', NOW(), NOW(), NULL) g ON gp.`group_id` = g.`id` AND g.deleted_at IS NULL WHERE m.`status` = 'joined' AND NOT (ISNULL(g.`hash`) AND p.`hash` NOT LIKE '') AND m.deleted_at IS NULL" | ||
sGetModuleFieldSQL string = "SELECT `%s` FROM `modules` WHERE `id` = ? LIMIT 1" | ||
sSetModuleFieldSQL string = "UPDATE `modules` SET `%s` = ? WHERE `id` = ?" | ||
sLoadModulesSQL string = ` | ||
SELECT | ||
m.id | ||
, IFNULL(g.hash, '') AS group_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can just ignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This technique is necessary in order not to forget the comma when adding. Similar to how Go puts a comma at the end of a line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, writing in one line makes the constant absolutely unreadable for the developer. |
||
, IFNULL(p.hash, '') AS policy_id | ||
, m.info | ||
, m.last_update | ||
, m.last_module_update | ||
, m.state | ||
, m.template | ||
FROM modules m | ||
LEFT JOIN ( | ||
SELECT * | ||
FROM policies | ||
UNION | ||
SELECT | ||
0 | ||
, '' | ||
, '{}' | ||
, NOW() | ||
, NOW() | ||
, NULL | ||
) p ON | ||
m.policy_id = p.id | ||
AND p.deleted_at IS NULL | ||
LEFT JOIN groups_to_policies gp | ||
ON gp.policy_id = p.id | ||
LEFT JOIN ( | ||
SELECT * | ||
FROM groups | ||
UNION | ||
SELECT | ||
0 | ||
, '' | ||
, '{}' | ||
, NOW() | ||
, NOW() | ||
, NULL | ||
) g ON | ||
gp.group_id = g.id | ||
AND g.deleted_at IS NULL | ||
WHERE m.status = 'joined' | ||
AND NOT (ISNULL(g.hash) | ||
AND p.hash NOT LIKE '') | ||
AND m.deleted_at IS NULL` | ||
|
||
sGetModuleFieldSQL string = ` | ||
SELECT %s | ||
FROM modules | ||
WHERE id = ? | ||
LIMIT 1` | ||
|
||
sSetModuleFieldSQL string = ` | ||
UPDATE modules | ||
SET %s = ? | ||
WHERE id = ?` | ||
) | ||
|
||
// tFilesLoaderType is type for loading module | ||
|
@@ -115,7 +168,9 @@ func (cl *configLoaderDB) load() ([]*loader.ModuleConfig, error) { | |
return nil, fmt.Errorf("failed to parse the module config: %w", err) | ||
} | ||
} else { | ||
return nil, fmt.Errorf("failed to load the module config: returned rows do not contain the field '%s'", moduleInfoField) | ||
return nil, fmt.Errorf( | ||
"failed to load the module config: returned rows do not contain the field '%s'", moduleInfoField, | ||
) | ||
} | ||
if groupID, ok := m["group_id"]; ok { | ||
mc.GroupID = groupID | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add
G307
into global excludes here https://github.com/vxcontrol/soldr/blob/master/.golangci.yml#L68Such wrappers everywhere in codebase is redundant and non-profitable. I will not add this comment in every place with the same pattern, please consider this comment for all files.