shawkinsl/mtga-tracker

View on GitHub
electron/mainRenderer.js

Summary

Maintainability
F
2 wks
Test Coverage

File mainRenderer.js has 1384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

console.time('init')

const request = require("request")
const crypto = require("crypto")
const ReconnectingWebSocket = require('./vendor/rws.js')
Severity: Major
Found in electron/mainRenderer.js - About 3 days to fix

    Function onMessage has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
    Open

    let onMessage = (data) => {
        data = JSON.parse(event.data)
        if (data.data_type == "game_state") {
            if (data.match_complete) {
    
    
    Severity: Minor
    Found in electron/mainRenderer.js - About 2 days 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 onMessage has 182 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    let onMessage = (data) => {
        data = JSON.parse(event.data)
        if (data.data_type == "game_state") {
            if (data.match_complete) {
    
    
    Severity: Major
    Found in electron/mainRenderer.js - About 7 hrs to fix

      Function cardtypeCompare has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      let cardtypeCompare = function (a, b) {
          // Creatures -> Planeswalkers -> Enchantments -> Artifacts -> Sorceries -> Instants -> Non-Basic Lands -> Basic Lands
          if (a.includes("Creature")) {
              if (!b.includes("Creature")) {
                  return -1;
      Severity: Minor
      Found in electron/mainRenderer.js - About 4 hrs 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 uploadGame has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function uploadGame(gameData) {
          const victory = gameData.players[0].name === gameData.winner;
      
          //only update per-deck win/loss for decks we know about
          const deckID = gameData.players[0].deck.deckID;
      Severity: Major
      Found in electron/mainRenderer.js - About 3 hrs to fix

        Function cardtypeCompare has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        let cardtypeCompare = function (a, b) {
            // Creatures -> Planeswalkers -> Enchantments -> Artifacts -> Sorceries -> Instants -> Non-Basic Lands -> Basic Lands
            if (a.includes("Creature")) {
                if (!b.includes("Creature")) {
                    return -1;
        Severity: Major
        Found in electron/mainRenderer.js - About 2 hrs to fix

          Function buildMenuItem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          let buildMenuItem = (menu_item) => {
            let li = $('<li></li>')
            let item = $('<a></a>')
            item.text(menu_item.label)
          
          
          Severity: Minor
          Found in electron/mainRenderer.js - About 2 hrs 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 card_color has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          rivets.binders.card_color = function(el, value) {
            el.classList.remove("card-b")
            el.classList.remove("card-g")
            el.classList.remove("card-r")
            el.classList.remove("card-u")
          Severity: Minor
          Found in electron/mainRenderer.js - About 2 hrs 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 resizeWindow has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function resizeWindow() {
              let total = 0;
              $.each($(".card"), function(i, c) {
                  total += c.offsetHeight;
              })
          Severity: Minor
          Found in electron/mainRenderer.js - About 1 hr to fix

            Function card_color has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            rivets.binders.card_color = function(el, value) {
              el.classList.remove("card-b")
              el.classList.remove("card-g")
              el.classList.remove("card-r")
              el.classList.remove("card-u")
            Severity: Minor
            Found in electron/mainRenderer.js - About 1 hr to fix

              Function buildMenuItem has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              let buildMenuItem = (menu_item) => {
                let li = $('<li></li>')
                let item = $('<a></a>')
                item.text(menu_item.label)
              
              
              Severity: Minor
              Found in electron/mainRenderer.js - About 1 hr to fix

                Function cleanError has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                function cleanError(error, depth, maxDepth) {
                  if (depth === undefined) depth = 0;
                  if (maxDepth === undefined) maxDepth = 3;
                  if (depth >= maxDepth) return;
                  if (error && typeof error === 'object') {
                Severity: Minor
                Found in electron/mainRenderer.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 resizeWindow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function resizeWindow() {
                    let total = 0;
                    $.each($(".card"), function(i, c) {
                        total += c.offsetHeight;
                    })
                Severity: Minor
                Found in electron/mainRenderer.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 addMessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                var addMessage = (message, link, mustfollow, messageID) => {
                    if (!link) link = "#"
                    let existingMessage = appData.messages.filter(x => x["text"] == message && x["show"])
                    if (existingMessage.length) {
                      // we can just bump the count on this one
                Severity: Minor
                Found in electron/mainRenderer.js - About 55 mins 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 manasymbols has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                rivets.binders.manasymbols = (el,cost) => {
                  let $el = $(el);
                  $el.children().remove()
                
                  for (let symbol of cost){
                Severity: Minor
                Found in electron/mainRenderer.js - About 55 mins 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 cmcCompute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                let cmcCompute = function (card) {
                  //put lands at bottom
                  if ( card.card_type === 'Land'){
                    return 1000;
                  }
                Severity: Minor
                Found in electron/mainRenderer.js - About 55 mins 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 getColorValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                let getColorValue = function(card) {
                  let value = card.cardtype === 'Land' ? 32 : 0
                  for ( color of card.colors) {
                    if ( color === 'White' ){
                      value += 1
                Severity: Minor
                Found in electron/mainRenderer.js - About 55 mins 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

                Avoid deeply nested control flow statements.
                Open

                                if (gameLookup[data.gameID].count++ > 5) {
                                  if (!gameLookup[data.gameID].uploaded) {
                                    gameLookup[data.gameID].uploaded = true
                                    if (lastGameState) {
                                      uploadGame(lastGameState)
                Severity: Major
                Found in electron/mainRenderer.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (data.inventory.vaultProgress) {
                              appData.lastVaultProgress = data.inventory.vaultProgress;
                  
                              ipcRenderer.send("lastVaultProgressChanged",appData.lastVaultProgress)
                            }
                  Severity: Major
                  Found in electron/mainRenderer.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                            if (data.decks.no_decks_defined) {
                                appData.no_decks = true;
                            } else {
                                new_decks = []
                                $.each(data.decks, (key, value) => {
                    Severity: Major
                    Found in electron/mainRenderer.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if (appData.player_decks.map(deck=>deck.deck_id).includes(data.deck_id)){
                                      const deck = getDeckById(data.deck_id);
                                      appData.activeDeck = data.deck_id;
                                      const types = ['daily','alltime'];
                                      $.each(types, (i, type) => {
                      Severity: Major
                      Found in electron/mainRenderer.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                } else if (data.collection) {
                                  var cardQuantity;
                                  if (data.collection) {
                                    if(appData.lastCollection && (Object.keys(appData.lastCollection).length != 0)) {
                                      var objectToPush = {time:(new Date(Date.now())).toLocaleString(), cardsObtained:{}};
                        Severity: Major
                        Found in electron/mainRenderer.js - About 45 mins to fix

                          Function addClickHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          let addClickHandler = (selector,handler) => {
                            let new_handler = (e) => {
                              if (!$.contains($('.menu-div').get(0),event.target) && !$('#main-menu').hasClass('hide-me')){
                                e.preventDefault()
                                e.stopPropagation()
                          Severity: Minor
                          Found in electron/mainRenderer.js - About 35 mins 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

                          Avoid too many return statements within this function.
                          Open

                                  return 0;
                          Severity: Major
                          Found in electron/mainRenderer.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return 0;
                            Severity: Major
                            Found in electron/mainRenderer.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return 0;
                              Severity: Major
                              Found in electron/mainRenderer.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return 0;
                                Severity: Major
                                Found in electron/mainRenderer.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return 0;
                                  Severity: Major
                                  Found in electron/mainRenderer.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return 1;
                                    Severity: Major
                                    Found in electron/mainRenderer.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return 1;
                                      Severity: Major
                                      Found in electron/mainRenderer.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return 1;
                                        Severity: Major
                                        Found in electron/mainRenderer.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                  return 1;
                                          Severity: Major
                                          Found in electron/mainRenderer.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return 0;
                                            Severity: Major
                                            Found in electron/mainRenderer.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return 1;
                                              Severity: Major
                                              Found in electron/mainRenderer.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return -1;
                                                Severity: Major
                                                Found in electron/mainRenderer.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                              return -1;
                                                  Severity: Major
                                                  Found in electron/mainRenderer.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return -1;
                                                    Severity: Major
                                                    Found in electron/mainRenderer.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                              return 1;
                                                      Severity: Major
                                                      Found in electron/mainRenderer.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                return 0;
                                                        Severity: Major
                                                        Found in electron/mainRenderer.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                      return -1;
                                                          Severity: Major
                                                          Found in electron/mainRenderer.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                    return -1;
                                                            Severity: Major
                                                            Found in electron/mainRenderer.js - About 30 mins to fix

                                                              Function decklistSort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                              Open

                                                              rivets.formatters.decklistSort = function(decklist) {
                                                                  if (decklist.length === 0) {
                                                                      return decklist;
                                                                  }
                                                              
                                                              
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js - About 25 mins 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 updateTitleWidth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                              Open

                                                              let updateTitleWidth = () => {
                                                                let width = useMinimal ? 278 : 320
                                                                if (appData.showHideButton) {
                                                                  width -= 26
                                                                }
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js - About 25 mins 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 deckFrequencySubLists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                              Open

                                                              let deckFrequencySubLists = function (decklist) {
                                                                let card_count = -1;
                                                                let sublists = [];
                                                                let current_sublist = null;
                                                                let reverse_sort = function(a, b){return b.count_in_deck - a.count_in_deck}
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js - About 25 mins 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 2 locations. Consider refactoring.
                                                              Open

                                                                if (appData.mtgaOverlayOnly) {
                                                                  activeWin().then(win => {
                                                                    if (win.owner.name == "MTGA.exe" || win.owner.name == "MTGATracker.exe" || win.title == "MTGA Tracker") {
                                                                      if(!browserWindow.isAlwaysOnTop()) browserWindow.setAlwaysOnTop(true)
                                                                    } else {
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 4 hrs to fix
                                                              electron/historyRenderer.js on lines 33..44

                                                              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 121.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                  if (useTheme) {
                                                                    let head  = document.getElementsByTagName('head')[0];
                                                                    let link  = document.createElement('link');
                                                                    link.id   = 'theme';
                                                                    link.rel  = 'stylesheet';
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 3 hrs to fix
                                                              electron/mainRenderer.js on lines 1438..1447

                                                              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 113.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                  if (lastUseTheme) {
                                                                    let head  = document.getElementsByTagName('head')[0];
                                                                    let link  = document.createElement('link');
                                                                    link.id   = 'theme';
                                                                    link.rel  = 'stylesheet';
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 3 hrs to fix
                                                              electron/mainRenderer.js on lines 1567..1576

                                                              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 113.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                              if (debug) {
                                                                window.addEventListener('contextmenu', (e) => {
                                                                  e.preventDefault()
                                                                  rightClickPosition = {x: e.x, y: e.y}
                                                                  contextMenu.popup(remote.getCurrentWindow())
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 2 hrs to fix
                                                              electron/collectionRenderer.js on lines 93..99

                                                              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 80.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                      } else if (data.draftPick) {
                                                                        passThrough("draft-pick", data.draftPick, data.player_key).catch(e => {
                                                                          console.log("error uploading draftPick data: ")
                                                                          console.log(e)
                                                                        })
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 1 hr to fix
                                                              electron/mainRenderer.js on lines 1093..1173

                                                              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 57.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                      } else if (data.rank_change) {
                                                                        passThrough("rankChange", data.rank_change, data.player_key).catch(e => {
                                                                          console.log("error uploading rank data: ")
                                                                          console.log(e)
                                                                        })
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 1 other location - About 1 hr to fix
                                                              electron/mainRenderer.js on lines 1153..1173

                                                              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 57.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                        } else {
                                                                          appData.winLossObj[type][deckID] = {win: 0, loss: 1, name: gameData.players[0].deck.poolName};
                                                                        }
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 55 mins to fix
                                                              electron/mainRenderer.js on lines 903..905

                                                              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 54.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                        if (victory) {
                                                                          appData.winLossObj[type][deckID] = {win: 1, loss: 0, name: gameData.players[0].deck.poolName};
                                                                        } else {
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 55 mins to fix
                                                              electron/mainRenderer.js on lines 905..907

                                                              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 54.

                                                              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 5 locations. Consider refactoring.
                                                              Open

                                                              const contextMenuItem = new MenuItem({
                                                                label: 'Inspect Element',
                                                                click: () => {
                                                                  remote.getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y)
                                                                }
                                                              Severity: Major
                                                              Found in electron/mainRenderer.js and 4 other locations - About 55 mins to fix
                                                              electron/inspector/js/main.js on lines 74..79
                                                              electron/collectionRenderer.js on lines 85..90
                                                              electron/historyRenderer.js on lines 49..54
                                                              electron/settingsRenderer.js on lines 123..128

                                                              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 54.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                          } else {
                                                                              opponentTimer.pause()
                                                                              heroTimer.start()
                                                                              $("#opponent-timer").addClass("active")
                                                                              $("#hero-timer").removeClass("active")
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 55 mins to fix
                                                              electron/mainRenderer.js on lines 1159..1164

                                                              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 53.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                          if (data.heroIsDeciding) {
                                                                              opponentTimer.start()
                                                                              heroTimer.pause()
                                                                              $("#opponent-timer").removeClass("active")
                                                                              $("#hero-timer").addClass("active")
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 55 mins to fix
                                                              electron/mainRenderer.js on lines 1164..1169

                                                              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 53.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                  } else {
                                                                    appData.winLossObj.alltime.total.loss++;
                                                                    appData.winLossObj.daily.total.loss++;
                                                                  }
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 30 mins to fix
                                                              electron/mainRenderer.js on lines 916..919

                                                              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 45.

                                                              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 2 locations. Consider refactoring.
                                                              Open

                                                                  if (victory) {
                                                                    appData.winLossObj.alltime.total.win++;
                                                                    appData.winLossObj.daily.total.win++;
                                                                  } else {
                                                              Severity: Minor
                                                              Found in electron/mainRenderer.js and 1 other location - About 30 mins to fix
                                                              electron/mainRenderer.js on lines 919..922

                                                              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 45.

                                                              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

                                                              There are no issues that match your filters.

                                                              Category
                                                              Status