General Code Audit
alikindsys opened this issue · 8 comments
Meta-issue with all points on the code base that may need to be looked again. If said issue is big enough another issue may be created because of it. For better organization, new issues must be posted as a comment first then edited on the original message.
Reason : Discord webhook only notifies new comments not edits.
Issues here can range from code quality to major bugs.
Tags
NRE
- Can cause / causes a NullReferenceException.
EXC
- Can cause / causes an unhandled exception.
CQ
- Code Quality.
BUG
- Any bug. Includes unexpected behavior.
API
- Issues on the current API design. Should have an proposal that addresses said issue annexed.
Format
Use the copy permalink feature on github and describe the issue on that piece of code.
List
CQ
| API
- Behaviours
class works like a namespace, unnecessary nesting.
CQ
| API
- Behaviours
class works like a namespace, unnecessary nesting.
Lines 6 to 11 in 64c33b8
This makes the calling side to have the following code:
using static sisbase.Utils.Behaviours;
Proposed solution
Remove the nesting and move said enums to their own namespace so the calling side would be this instead:
using sisbase.Utils.Enums;
CQ
| API
- EmbedBase.ListEmbed uses IEnumerable<T>
which is inconsistent with the api name, and likely could cause issues since IEnumerable
can be anything that provides an enumerator.
Eg :
Dictionary<T>
ConcurrentDictionary<T>
ConcurrentBag<T>
...
Line 163
in
64c33b8
Proposed Solution
Line 163 in 64c33b8
Change the function declaration to use an List<T>
or IList<T>
.
CQ
- Complex nested code could be made into a function
Lines 182 to 204 in 64c33b8
CQ
- Manual foreach be simplified by a linq expression
Lines 56 to 62
in
64c33b8
Proposed expression
Lines 56 to 62 in 64c33b8
var groups = RegisteredCommands.Where(x => x is CommandGroup).Distinct();
CQ
| API
- Unused inferface. Should be deprecated/removed.
sisbase/Utils/IStaticSystem.cs
Lines 3 to 8 in 64c33b8
CQ
- Poor variable names
Lines 34 to 35 in 64c33b8
BUG
| EXC
- Non-exaustive call to string.Join
which generates null
once a list is empty. Embed fields can't have null
values leading to an invalid embed generation.
Lines 64 to 67 in 64c33b8