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 || {};
  }
Severity: Major
Found in server/lib/userIntroducer.js - About 2 hrs to fix

    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;
      }
    Severity: Minor
    Found in server/backends/irc/connection-manager/connectionManager.js - About 2 hrs to fix

      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);
      Severity: Minor
      Found in new-client/src/components/SidebarMenu.tsx - About 2 hrs to fix

        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;
          }
        
        
        Severity: Minor
        Found in server/services/windows.js - About 1 hr to fix

          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;
          Severity: Minor
          Found in server/backends/irc/controller.js - About 1 hr to fix

            Function constructor has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor({
                id,
                peerUser,
                network,
                operators,
            Severity: Minor
            Found in new-client/src/models/Window.ts - About 1 hr to fix

              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'));
              Severity: Minor
              Found in server/lib/log.ts - About 1 hr to fix

                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>('');
                Severity: Minor
                Found in new-client/src/components/JoinIRCChannel.tsx - About 1 hr to fix

                  Function _drawCursor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _drawCursor(cursor) {
                      if (cursor.x === null) {
                        $('#window-cursor').hide();
                        return;
                      }
                  Severity: Minor
                  Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in server/lib/notification.js - About 1 hr to fix

                  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, {
                  Severity: Major
                  Found in new-client/src/stores/ModalStore.ts and 2 other locations - About 1 hr to fix
                  new-client/src/stores/AlertStore.ts on lines 14..24
                  new-client/src/stores/ProfileStore.ts on lines 19..29

                  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

                  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, {
                  Severity: Major
                  Found in new-client/src/stores/ProfileStore.ts and 2 other locations - About 1 hr to fix
                  new-client/src/stores/AlertStore.ts on lines 14..24
                  new-client/src/stores/ModalStore.ts on lines 11..21

                  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

                  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, {
                  Severity: Major
                  Found in new-client/src/stores/AlertStore.ts and 2 other locations - About 1 hr to fix
                  new-client/src/stores/ModalStore.ts on lines 11..21
                  new-client/src/stores/ProfileStore.ts on lines 19..29

                  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

                  Further Reading

                  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();
                  
                  
                  Severity: Minor
                  Found in server/routes/router.js - About 1 hr to fix

                    Function createWindow has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function createWindow(user, conversation) {
                      let peerMember = null;
                    
                      assert(conversation);
                    
                    
                    Severity: Minor
                    Found in server/services/windows.js - About 1 hr to fix

                      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 = '';
                      
                      
                      Severity: Minor
                      Found in client/app/models/Message.js - About 1 hr to fix

                        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);
                        Severity: Minor
                        Found in server/backends/irc/controller.js - About 1 hr to fix

                          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);
                          Severity: Minor
                          Found in new-client/src/stores/WindowStore.ts - About 1 hr to fix

                            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;
                            
                            
                            Severity: Minor
                            Found in server/controllers/request.js - About 1 hr to fix

                            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();
                            
                            
                            Severity: Minor
                            Found in new-client/src/lib/socket.ts - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language