Showing 254 of 254 total issues
Function introduceUsers
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function introduceUsers(user, userGIds, session, socket) {
if (session) {
// If no session is given, force broadcast userGids without remembering them
session.knownUserGIds = session.knownUserGIds || {};
}
Function connect
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function connect(userId, nick, network) {
if (sockets[`${userId}:${network}`]) {
log.warn({ id: userId }, `Impossible happened. Already connected to IRC network: ${network}`);
return;
}
Function DesktopMenu
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const DesktopMenu: FunctionComponent = () => {
const navigate = useNavigate();
const { windowStore, profileStore } = useContext(ServerContext);
const handleLogout = (allSessions: boolean) => windowStore.handleLogout(allSessions);
Function scanMentions
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.scanMentions = async function scanMentions(conversation, message) {
if (!message.get('userGId') || message.get('userGId') === 'i0' || !message.get('body')) {
return;
}
Function handlePrivmsg
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function handlePrivmsg(user, msg, command) {
// :ilkkao!~ilkkao@127.0.0.1 NOTICE buppe :foo
const target = msg.params[0];
const currentNick = await nicksService.getNick(user.gId, msg.network);
let conversation;
Function constructor
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor({
id,
peerUser,
network,
operators,
Function configTransports
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function configTransports() {
const transports = [];
if (get('log:file')) {
let logDirectory = path.normalize(get('log:directory'));
Function Search
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Search: FunctionComponent = () => {
const navigate = useNavigate();
const toast = useToast();
const { windowStore } = useContext(ServerContext);
const [name, setName] = useState<string>('');
Function _drawCursor
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_drawCursor(cursor) {
if (cursor.x === null) {
$('#window-cursor').hide();
return;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function sendNotifications
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
async function sendNotifications(user, sessionId, excludeSessionId, ntfs) {
assert(ntfs);
const ntfsArray = (util.isArray(ntfs) ? ntfs : [ntfs]).map(ntf =>
typeof ntf === 'string' ? ntf : JSON.stringify(ntf)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 3 locations. Consider refactoring. Open
constructor(rootStore: RootStore, socket: Socket) {
this.rootStore = rootStore;
this.socket = socket;
makeObservable(this, {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 73.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
constructor(rootStore: RootStore, socket: Socket) {
this.rootStore = rootStore;
this.socket = socket;
makeObservable(this, {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 73.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
constructor(rootStore: RootStore, socket: Socket) {
this.rootStore = rootStore;
this.socket = socket;
makeObservable(this, {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 73.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function buildRouter
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function buildRouter() {
log.info('Registering app routes');
const router = new Router();
Function createWindow
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createWindow(user, conversation) {
let peerMember = null;
assert(conversation);
Function _parseLinks
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
_parseLinks(text) {
const imgSuffixes = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
const media = [];
let body = '';
Function handleJoin
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function handleJoin(user, msg) {
// :neo!i=ilkkao@iao.iki.fi JOIN :#testi4
const channel = msg.params[0];
const network = msg.network;
const targetUser = await nicksService.getUser(msg.nick, network);
Function handlerServerNotification
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
handlerServerNotification(ntf: Notification): boolean {
switch (ntf.type) {
case 'ADD_MESSAGE': {
const { type: _, windowId, ...message } = ntf;
this.addMessage(windowId, message);
Function process
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
exports.process = async function process(session, command) {
const { windowId } = command;
const network = typeof command.network === 'string' ? command.network.toLowerCase() : null;
const user = session.user;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function constructor
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(rootStore: RootStore) {
this.rootStore = rootStore;
this.emitInit();