# Global Metrics

path: .metrics.nexits.average
old: 2.2231404958677685
new: 4.0588235294117645
path: .metrics.nexits.sum
old: 269.0
new: 69.0
path: .metrics.nargs.average
old: 1.2148760330578512
new: 1.8235294117647056
path: .metrics.nargs.sum
old: 147.0
new: 31.0
path: .metrics.cyclomatic.sum
old: 672.0
new: 169.0
path: .metrics.cyclomatic.average
old: 5.647058823529412
new: 9.38888888888889
path: .metrics.nom.total
old: 121.0
new: 17.0
path: .metrics.nom.functions
old: 114.0
new: 17.0
path: .metrics.nom.closures
old: 7.0
new: 0.0
path: .metrics.mi.mi_sei
old: -238.15610159909355
new: -75.49145458087706
path: .metrics.mi.mi_original
old: -178.61845145353874
new: -31.287511854549948
path: .metrics.loc.ploc
old: 2762.0
new: 633.0
path: .metrics.loc.sloc
old: 3828.0
new: 900.0
path: .metrics.loc.cloc
old: 511.0
new: 134.0
path: .metrics.loc.lloc
old: 1271.0
new: 352.0
path: .metrics.loc.blank
old: 555.0
new: 133.0
path: .metrics.halstead.N2
old: 5280.0
new: 1419.0
path: .metrics.halstead.effort
old: 10790239.44114572
new: 2345934.186983239
path: .metrics.halstead.bugs
old: 16.276691542079224
new: 5.88512865523132
path: .metrics.halstead.estimated_program_length
old: 13453.49758541569
new: 2862.438235874812
path: .metrics.halstead.vocabulary
old: 1322.0
new: 358.0
path: .metrics.halstead.level
old: 0.01246114996114996
new: 0.011868995957123252
path: .metrics.halstead.N1
old: 7688.0
new: 1863.0
path: .metrics.halstead.difficulty
old: 80.2494154325799
new: 84.253125
path: .metrics.halstead.n1
old: 39.0
new: 38.0
path: .metrics.halstead.length
old: 12968.0
new: 3282.0
path: .metrics.halstead.volume
old: 134458.79179283176
new: 27843.88338098129
path: .metrics.halstead.time
old: 599457.7467303178
new: 130329.67705462438
path: .metrics.halstead.n2
old: 1283.0
new: 320.0
path: .metrics.halstead.purity_ratio
old: 1.0374381234897971
new: 0.8721627775365058
path: .metrics.cognitive.average
old: 5.43801652892562
new: 18.11764705882353
path: .metrics.cognitive.sum
old: 658.0
new: 308.0

# Spaces Data

## Minimal test - lines (589, 883)

path: .spaces[15].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[15].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[15].metrics.halstead.vocabulary
old: 13.0
new: 105.0
path: .spaces[15].metrics.halstead.purity_ratio
old: 1.5287504112491377
new: 0.5352506010737874
path: .spaces[15].metrics.halstead.n2
old: 6.0
new: 81.0
path: .spaces[15].metrics.halstead.level
old: 0.1904761904761905
new: 0.013581488933601608
path: .spaces[15].metrics.halstead.volume
old: 85.11011351724513
new: 7822.096028081032
path: .spaces[15].metrics.halstead.N1
old: 14.0
new: 668.0
path: .spaces[15].metrics.halstead.length
old: 23.0
new: 1165.0
path: .spaces[15].metrics.halstead.N2
old: 9.0
new: 497.0
path: .spaces[15].metrics.halstead.difficulty
old: 5.25
new: 73.62962962962963
path: .spaces[15].metrics.halstead.estimated_program_length
old: 35.161259458730164
new: 623.5669502509623
path: .spaces[15].metrics.halstead.bugs
old: 0.019482247700101516
new: 2.307433807313031
path: .spaces[15].metrics.halstead.effort
old: 446.828095965537
new: 575938.0334750034
path: .spaces[15].metrics.halstead.time
old: 24.823783109196498
new: 31996.55741527797
path: .spaces[15].metrics.halstead.n1
old: 7.0
new: 24.0
path: .spaces[15].metrics.cognitive.average
old: 1.0
new: 193.0
path: .spaces[15].metrics.cognitive.sum
old: 1.0
new: 193.0
path: .spaces[15].metrics.loc.cloc
old: 0.0
new: 35.0
path: .spaces[15].metrics.loc.blank
old: 1.0
new: 41.0
path: .spaces[15].metrics.loc.lloc
old: 3.0
new: 123.0
path: .spaces[15].metrics.loc.ploc
old: 7.0
new: 219.0
path: .spaces[15].metrics.loc.sloc
old: 8.0
new: 295.0
path: .spaces[15].metrics.mi.mi_visual_studio
old: 66.5172681252867
new: 9.58158976689091
path: .spaces[15].metrics.mi.mi_sei
old: 88.60145491368996
new: -19.60493211857557
path: .spaces[15].metrics.mi.mi_original
old: 113.74452849424026
new: 16.384518501383454
path: .spaces[15].metrics.nexits.sum
old: 1.0
new: 4.0
path: .spaces[15].metrics.nexits.average
old: 1.0
new: 4.0
path: .spaces[15].metrics.cyclomatic.average
old: 2.0
new: 69.0
path: .spaces[15].metrics.cyclomatic.sum
old: 2.0
new: 69.0

### Code

    nsMIMEInfoWin::GetPossibleLocalHandlers(nsIArray** _retval) {
      nsresult rv;

      *_retval = nullptr;

      nsCOMPtr appList = do_CreateInstance("@mozilla.org/array;1");

      if (!appList) return NS_ERROR_FAILURE;

      nsTArray trackList;

      nsAutoCString fileExt;
      GetPrimaryExtension(fileExt);

      nsCOMPtr regKey =
          do_CreateInstance("@mozilla.org/windows-registry-key;1");
      if (!regKey) return NS_ERROR_FAILURE;
      nsCOMPtr appKey =
          do_CreateInstance("@mozilla.org/windows-registry-key;1");
      if (!appKey) return NS_ERROR_FAILURE;

      nsAutoString workingRegistryPath;

      bool extKnown = false;
      if (fileExt.IsEmpty()) {
        extKnown = true;
        // Mime type discovery is possible in some cases, through
        // HKEY_CLASSES_ROOT\MIME\Database\Content Type, however, a number
        // of file extensions related to mime type are simply not defined,
        // (application/rss+xml & application/atom+xml are good examples)
        // in which case we can only provide a generic list.
        nsAutoCString mimeType;
        GetMIMEType(mimeType);
        if (!mimeType.IsEmpty()) {
          workingRegistryPath.AppendLiteral("MIME\\Database\\Content Type\\");
          workingRegistryPath.Append(NS_ConvertASCIItoUTF16(mimeType));

          rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                            workingRegistryPath,
                            nsIWindowsRegKey::ACCESS_QUERY_VALUE);
          if (NS_SUCCEEDED(rv)) {
            nsAutoString mimeFileExt;
            if (NS_SUCCEEDED(regKey->ReadStringValue(u""_ns, mimeFileExt))) {
              CopyUTF16toUTF8(mimeFileExt, fileExt);
              extKnown = false;
            }
          }
        }
      }

      nsAutoString fileExtToUse;
      if (!fileExt.IsEmpty() && fileExt.First() != '.') {
        fileExtToUse = char16_t('.');
      }
      fileExtToUse.Append(NS_ConvertUTF8toUTF16(fileExt));

      // Note, the order in which these occur has an effect on the
      // validity of the resulting display list.

      if (!extKnown) {
        // 1) Get the default handler if it exists
        workingRegistryPath = fileExtToUse;

        rv =
            regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                         workingRegistryPath, nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          nsAutoString appProgId;
          if (NS_SUCCEEDED(regKey->ReadStringValue(u""_ns, appProgId))) {
            // Bug 358297 - ignore the embedded internet explorer handler
            if (appProgId != u"XPSViewer.Document"_ns) {
              nsAutoString appFilesystemCommand;
              if (GetProgIDVerbCommandHandler(appProgId, appFilesystemCommand,
                                              false) &&
                  !IsPathInList(appFilesystemCommand, trackList)) {
                ProcessPath(appList, trackList, appFilesystemCommand);
              }
            }
          }
          regKey->Close();
        }

        // 2) list HKEY_CLASSES_ROOT\.ext\OpenWithList

        workingRegistryPath = fileExtToUse;
        workingRegistryPath.AppendLiteral("\\OpenWithList");

        rv =
            regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                         workingRegistryPath, nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          uint32_t count = 0;
          if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
            for (uint32_t index = 0; index < count; index++) {
              nsAutoString appName;
              if (NS_FAILED(regKey->GetValueName(index, appName))) continue;

              // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
              nsAutoString appFilesystemCommand;
              if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand,
                                             false) ||
                  IsPathInList(appFilesystemCommand, trackList))
                continue;
              ProcessPath(appList, trackList, appFilesystemCommand);
            }
          }
          regKey->Close();
        }

        // 3) List HKEY_CLASSES_ROOT\.ext\OpenWithProgids, with the
        // different step of resolving the progids for the command handler.

        workingRegistryPath = fileExtToUse;
        workingRegistryPath.AppendLiteral("\\OpenWithProgids");

        rv =
            regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                         workingRegistryPath, nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          uint32_t count = 0;
          if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
            for (uint32_t index = 0; index < count; index++) {
              // HKEY_CLASSES_ROOT\.ext\OpenWithProgids\Windows.XPSReachViewer
              nsAutoString appProgId;
              if (NS_FAILED(regKey->GetValueName(index, appProgId))) continue;

              nsAutoString appFilesystemCommand;
              if (!GetProgIDVerbCommandHandler(appProgId, appFilesystemCommand,
                                               false) ||
                  IsPathInList(appFilesystemCommand, trackList))
                continue;
              ProcessPath(appList, trackList, appFilesystemCommand);
            }
          }
          regKey->Close();
        }

        // 4) Add any non configured applications located in the MRU list

        // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion
        // \Explorer\FileExts\.ext\OpenWithList
        workingRegistryPath = nsLiteralString(
            u"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\");
        workingRegistryPath += fileExtToUse;
        workingRegistryPath.AppendLiteral("\\OpenWithList");

        rv =
            regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
                         workingRegistryPath, nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          uint32_t count = 0;
          if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
            for (uint32_t index = 0; index < count; index++) {
              nsAutoString appName, appValue;
              if (NS_FAILED(regKey->GetValueName(index, appName))) continue;
              if (appName.EqualsLiteral("MRUList")) continue;
              if (NS_FAILED(regKey->ReadStringValue(appName, appValue))) continue;

              // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
              nsAutoString appFilesystemCommand;
              if (!GetAppsVerbCommandHandler(appValue, appFilesystemCommand,
                                             false) ||
                  IsPathInList(appFilesystemCommand, trackList))
                continue;
              ProcessPath(appList, trackList, appFilesystemCommand);
            }
          }
        }

        // 5) Add any non configured progids in the MRU list, with the
        // different step of resolving the progids for the command handler.

        // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion
        // \Explorer\FileExts\.ext\OpenWithProgids
        workingRegistryPath = nsLiteralString(
            u"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\");
        workingRegistryPath += fileExtToUse;
        workingRegistryPath.AppendLiteral("\\OpenWithProgids");

        regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, workingRegistryPath,
                     nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          uint32_t count = 0;
          if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
            for (uint32_t index = 0; index < count; index++) {
              nsAutoString appIndex, appProgId;
              if (NS_FAILED(regKey->GetValueName(index, appProgId))) continue;

              nsAutoString appFilesystemCommand;
              if (!GetProgIDVerbCommandHandler(appProgId, appFilesystemCommand,
                                               false) ||
                  IsPathInList(appFilesystemCommand, trackList))
                continue;
              ProcessPath(appList, trackList, appFilesystemCommand);
            }
          }
          regKey->Close();
        }

        // 6) Check the perceived type value, and use this to lookup the
        // perceivedtype open with list.
        // http://msdn2.microsoft.com/en-us/library/aa969373.aspx

        workingRegistryPath = fileExtToUse;

        regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, workingRegistryPath,
                     nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          nsAutoString perceivedType;
          rv = regKey->ReadStringValue(u"PerceivedType"_ns, perceivedType);
          if (NS_SUCCEEDED(rv)) {
            nsAutoString openWithListPath(u"SystemFileAssociations\\"_ns);
            openWithListPath.Append(perceivedType);  // no period
            openWithListPath.AppendLiteral("\\OpenWithList");

            nsresult rv = appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                                       openWithListPath,
                                       nsIWindowsRegKey::ACCESS_QUERY_VALUE);
            if (NS_SUCCEEDED(rv)) {
              uint32_t count = 0;
              if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
                for (uint32_t index = 0; index < count; index++) {
                  nsAutoString appName;
                  if (NS_FAILED(regKey->GetValueName(index, appName))) continue;

                  // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
                  nsAutoString appFilesystemCommand;
                  if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand,
                                                 false) ||
                      IsPathInList(appFilesystemCommand, trackList))
                    continue;
                  ProcessPath(appList, trackList, appFilesystemCommand);
                }
              }
            }
          }
        }
      }  // extKnown == false

      // 7) list global HKEY_CLASSES_ROOT\*\OpenWithList
      // Listing general purpose handlers, not specific to a mime type or file
      // extension

      workingRegistryPath = u"*\\OpenWithList"_ns;

      rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                        workingRegistryPath, nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_SUCCEEDED(rv)) {
        uint32_t count = 0;
        if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
          for (uint32_t index = 0; index < count; index++) {
            nsAutoString appName;
            if (NS_FAILED(regKey->GetValueName(index, appName))) continue;

            // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
            nsAutoString appFilesystemCommand;
            if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand, false) ||
                IsPathInList(appFilesystemCommand, trackList))
              continue;
            ProcessPath(appList, trackList, appFilesystemCommand);
          }
        }
        regKey->Close();
      }

      // 8) General application's list - not file extension specific on windows
      workingRegistryPath = u"Applications"_ns;

      rv =
          regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, workingRegistryPath,
                       nsIWindowsRegKey::ACCESS_ENUMERATE_SUB_KEYS |
                           nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_SUCCEEDED(rv)) {
        uint32_t count = 0;
        if (NS_SUCCEEDED(regKey->GetChildCount(&count)) && count > 0) {
          for (uint32_t index = 0; index < count; index++) {
            nsAutoString appName;
            if (NS_FAILED(regKey->GetChildName(index, appName))) continue;

            // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
            nsAutoString appFilesystemCommand;
            if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand, false) ||
                IsPathInList(appFilesystemCommand, trackList))
              continue;
            ProcessPath(appList, trackList, appFilesystemCommand);
          }
        }
      }

      // Return to the caller
      *_retval = appList;
      NS_ADDREF(*_retval);

      return NS_OK;
    }

## Minimal test - lines (34, 41)

path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[1].metrics.loc.ploc
old: 7.0
new: 6.0
path: .spaces[1].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nexits.average
old: 0.0
new: 2.0
path: .spaces[1].metrics.mi.mi_original
old: 113.46221967158316
new: 111.21997190130568
path: .spaces[1].metrics.mi.mi_sei
old: 88.1941693752434
new: 110.9965046122558
path: .spaces[1].metrics.mi.mi_visual_studio
old: 66.35217524653987
new: 65.04091924052965
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.8978906284523145
new: 2.0807210255622213
path: .spaces[1].metrics.halstead.bugs
old: 0.018419850233283287
new: 0.03549273314566324
path: .spaces[1].metrics.halstead.difficulty
old: 4.571428571428571
new: 7.944444444444445
path: .spaces[1].metrics.halstead.N1
old: 15.0
new: 19.0
path: .spaces[1].metrics.halstead.N2
old: 8.0
new: 13.0
path: .spaces[1].metrics.halstead.length
old: 23.0
new: 32.0
path: .spaces[1].metrics.halstead.time
old: 22.821202209268804
new: 61.04056469816226
path: .spaces[1].metrics.halstead.volume
old: 89.85848369899593
new: 138.3016990363956
path: .spaces[1].metrics.halstead.effort
old: 410.7816397668385
new: 1098.7301645669206
path: .spaces[1].metrics.halstead.estimated_program_length
old: 43.65148445440323
new: 66.58307281799108
path: .spaces[1].metrics.halstead.vocabulary
old: 15.0
new: 20.0
path: .spaces[1].metrics.halstead.n2
old: 7.0
new: 9.0
path: .spaces[1].metrics.halstead.level
old: 0.21875
new: 0.12587412587412586
path: .spaces[1].metrics.halstead.n1
old: 8.0
new: 11.0

### Code

    nsresult nsMIMEInfoWin::LaunchDefaultWithFile(nsIFile* aFile) {
      // Launch the file, unless it is an executable.
      bool executable = true;
      aFile->IsExecutable(&executable);
      if (executable) return NS_ERROR_FAILURE;

      return aFile->Launch();
    }

## Minimal test - lines (32, 32)

path: .spaces[0].metrics.nargs.average
old: 4.0
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[0].metrics.halstead.N2
old: 56.0
new: 1.0
path: .spaces[0].metrics.halstead.N1
old: 60.0
new: 4.0
path: .spaces[0].metrics.halstead.bugs
old: 0.1090169394655468
new: 0.002712967490108627
path: .spaces[0].metrics.halstead.estimated_program_length
old: 235.76932453692504
new: 8.0
path: .spaces[0].metrics.halstead.volume
old: 651.3063419173642
new: 11.60964047443681
path: .spaces[0].metrics.halstead.level
old: 0.11011904761904764
new: 0.5
path: .spaces[0].metrics.halstead.vocabulary
old: 49.0
new: 5.0
path: .spaces[0].metrics.halstead.n2
old: 37.0
new: 1.0
path: .spaces[0].metrics.halstead.time
old: 328.5869833096612
new: 1.289960052715201
path: .spaces[0].metrics.halstead.effort
old: 5914.565699573902
new: 23.21928094887362
path: .spaces[0].metrics.halstead.length
old: 116.0
new: 5.0
path: .spaces[0].metrics.halstead.difficulty
old: 9.08108108108108
new: 2.0
path: .spaces[0].metrics.halstead.n1
old: 12.0
new: 4.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 2.0324941770424574
new: 1.6
path: .spaces[0].metrics.mi.mi_visual_studio
old: 49.29715763120203
new: 92.40962204246613
path: .spaces[0].metrics.mi.mi_original
old: 84.29813954935548
new: 158.02045369261705
path: .spaces[0].metrics.mi.mi_sei
old: 46.01747575141269
new: 152.37629276875444
path: .spaces[0].metrics.loc.sloc
old: 26.0
new: 1.0
path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 0.0
path: .spaces[0].metrics.loc.ploc
old: 26.0
new: 1.0

### Code

    nsMIMEInfoWin::~nsMIMEInfoWin() {}

## Minimal test - lines (567, 577)

path: .spaces[14].metrics.cyclomatic.sum
old: 5.0
new: 3.0
path: .spaces[14].metrics.cyclomatic.average
old: 5.0
new: 3.0
path: .spaces[14].metrics.loc.ploc
old: 22.0
new: 8.0
path: .spaces[14].metrics.loc.blank
old: 4.0
new: 1.0
path: .spaces[14].metrics.loc.cloc
old: 1.0
new: 2.0
path: .spaces[14].metrics.loc.lloc
old: 15.0
new: 5.0
path: .spaces[14].metrics.loc.sloc
old: 27.0
new: 11.0
path: .spaces[14].metrics.cognitive.sum
old: 4.0
new: 3.0
path: .spaces[14].metrics.cognitive.average
old: 4.0
new: 3.0
path: .spaces[14].metrics.halstead.bugs
old: 0.0907920798194094
new: 0.07092347644524839
path: .spaces[14].metrics.halstead.difficulty
old: 9.25
new: 11.5
path: .spaces[14].metrics.halstead.n2
old: 24.0
new: 15.0
path: .spaces[14].metrics.halstead.purity_ratio
old: 1.6282835109144853
new: 2.131031233968283
path: .spaces[14].metrics.halstead.level
old: 0.10810810810810811
new: 0.08695652173913043
path: .spaces[14].metrics.halstead.volume
old: 485.9729501355773
new: 269.8789827584685
path: .spaces[14].metrics.halstead.vocabulary
old: 36.0
new: 30.0
path: .spaces[14].metrics.halstead.estimated_program_length
old: 153.0586500259616
new: 117.20671786825557
path: .spaces[14].metrics.halstead.effort
old: 4495.24978875409
new: 3103.608301722388
path: .spaces[14].metrics.halstead.length
old: 94.0
new: 55.0
path: .spaces[14].metrics.halstead.N2
old: 37.0
new: 23.0
path: .spaces[14].metrics.halstead.n1
old: 12.0
new: 15.0
path: .spaces[14].metrics.halstead.time
old: 249.73609937522724
new: 172.42268342902153
path: .spaces[14].metrics.halstead.N1
old: 57.0
new: 32.0
path: .spaces[14].metrics.nargs.average
old: 1.0
new: 2.0
path: .spaces[14].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[14].metrics.mi.mi_visual_studio
old: 49.292074477730786
new: 59.856510888178285
path: .spaces[14].metrics.mi.mi_original
old: 84.28944735691965
new: 102.35463361878487
path: .spaces[14].metrics.mi.mi_sei
old: 61.09946810009492
new: 102.94980840090676

### Code

    static bool IsPathInList(nsAString& appPath, nsTArray& trackList) {
      // trackList data is always lowercase, see ProcessPath
      // above.
      nsAutoString tmp(appPath);
      ToLowerCase(tmp);

      for (uint32_t i = 0; i < trackList.Length(); i++) {
        if (tmp.Equals(trackList[i])) return true;
      }
      return false;
    }

## Minimal test - lines (219, 230)

path: .spaces[5].metrics.nexits.sum
old: 5.0
new: 1.0
path: .spaces[5].metrics.nexits.average
old: 5.0
new: 1.0
path: .spaces[5].metrics.halstead.difficulty
old: 16.38095238095238
new: 11.0
path: .spaces[5].metrics.halstead.N2
old: 86.0
new: 32.0
path: .spaces[5].metrics.halstead.purity_ratio
old: 1.3637433415807885
new: 1.5231902657464218
path: .spaces[5].metrics.halstead.length
old: 213.0
new: 67.0
path: .spaces[5].metrics.halstead.time
old: 1135.518474801554
new: 194.68622717191536
path: .spaces[5].metrics.halstead.volume
old: 1247.7499519621729
new: 318.5774626449524
path: .spaces[5].metrics.halstead.effort
old: 20439.332546427973
new: 3504.3520890944765
path: .spaces[5].metrics.halstead.estimated_program_length
old: 290.47733175670794
new: 102.05374780501026
path: .spaces[5].metrics.halstead.n1
old: 16.0
new: 11.0
path: .spaces[5].metrics.halstead.n2
old: 42.0
new: 16.0
path: .spaces[5].metrics.halstead.level
old: 0.06104651162790698
new: 0.09090909090909093
path: .spaces[5].metrics.halstead.vocabulary
old: 58.0
new: 27.0
path: .spaces[5].metrics.halstead.N1
old: 127.0
new: 35.0
path: .spaces[5].metrics.halstead.bugs
old: 0.24918575881434213
new: 0.07690429018027643
path: .spaces[5].metrics.mi.mi_sei
old: 51.31989385315857
new: 68.99300541542662
path: .spaces[5].metrics.mi.mi_visual_studio
old: 38.373987102881394
new: 58.52772564964662
path: .spaces[5].metrics.mi.mi_original
old: 65.61951794592719
new: 100.08241086089572
path: .spaces[5].metrics.cognitive.average
old: 10.0
new: 2.0
path: .spaces[5].metrics.cognitive.sum
old: 10.0
new: 2.0
path: .spaces[5].metrics.loc.sloc
old: 58.0
new: 12.0
path: .spaces[5].metrics.loc.cloc
old: 11.0
new: 0.0
path: .spaces[5].metrics.loc.blank
old: 8.0
new: 3.0
path: .spaces[5].metrics.loc.lloc
old: 17.0
new: 7.0
path: .spaces[5].metrics.loc.ploc
old: 39.0
new: 9.0
path: .spaces[5].metrics.nargs.average
old: 4.0
new: 1.0
path: .spaces[5].metrics.nargs.sum
old: 4.0
new: 1.0
path: .spaces[5].metrics.cyclomatic.average
old: 11.0
new: 3.0
path: .spaces[5].metrics.cyclomatic.sum
old: 11.0
new: 3.0

### Code

    nsMIMEInfoWin::GetEnumerator(nsISimpleEnumerator** _retval) {
      nsCOMArray properties;

      nsCOMPtr variant;
      GetProperty(u"defaultApplicationIconURL"_ns, getter_AddRefs(variant));
      if (variant) properties.AppendObject(variant);

      GetProperty(u"customApplicationIconURL"_ns, getter_AddRefs(variant));
      if (variant) properties.AppendObject(variant);

      return NS_NewArrayEnumerator(_retval, properties, NS_GET_IID(nsIVariant));
    }

## Minimal test - lines (232, 242)

path: .spaces[6].metrics.mi.mi_sei
old: 78.2666833002787
new: 72.20445657367502
path: .spaces[6].metrics.mi.mi_original
old: 82.96737467460255
new: 102.449571473684
path: .spaces[6].metrics.mi.mi_visual_studio
old: 48.51893255824711
new: 59.912030101569584
path: .spaces[6].metrics.nexits.average
old: 4.0
new: 1.0
path: .spaces[6].metrics.nexits.sum
old: 4.0
new: 1.0
path: .spaces[6].metrics.cognitive.average
old: 8.0
new: 0.0
path: .spaces[6].metrics.cognitive.sum
old: 8.0
new: 0.0
path: .spaces[6].metrics.cyclomatic.sum
old: 9.0
new: 1.0
path: .spaces[6].metrics.cyclomatic.average
old: 9.0
new: 1.0
path: .spaces[6].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[6].metrics.nargs.average
old: 1.0
new: 2.0
path: .spaces[6].metrics.halstead.effort
old: 7066.164631424202
new: 2798.563269695392
path: .spaces[6].metrics.halstead.n1
old: 17.0
new: 12.0
path: .spaces[6].metrics.halstead.N1
old: 60.0
new: 30.0
path: .spaces[6].metrics.halstead.bugs
old: 0.1227442753788319
new: 0.06619657177130547
path: .spaces[6].metrics.halstead.difficulty
old: 13.458333333333334
new: 9.666666666666666
path: .spaces[6].metrics.halstead.estimated_program_length
old: 179.5259683185635
new: 118.07820003461548
path: .spaces[6].metrics.halstead.time
old: 392.56470174578897
new: 155.47573720529957
path: .spaces[6].metrics.halstead.level
old: 0.07430340557275542
new: 0.10344827586206898
path: .spaces[6].metrics.halstead.purity_ratio
old: 1.8318976359037096
new: 2.001325424315517
path: .spaces[6].metrics.halstead.vocabulary
old: 41.0
new: 30.0
path: .spaces[6].metrics.halstead.volume
old: 525.0400964525722
new: 289.50654514090263
path: .spaces[6].metrics.halstead.n2
old: 24.0
new: 18.0
path: .spaces[6].metrics.halstead.N2
old: 38.0
new: 29.0
path: .spaces[6].metrics.halstead.length
old: 98.0
new: 59.0
path: .spaces[6].metrics.loc.ploc
old: 18.0
new: 11.0
path: .spaces[6].metrics.loc.blank
old: 3.0
new: 0.0
path: .spaces[6].metrics.loc.sloc
old: 27.0
new: 11.0
path: .spaces[6].metrics.loc.lloc
old: 7.0
new: 6.0
path: .spaces[6].metrics.loc.cloc
old: 6.0
new: 0.0

### Code

    static nsresult GetIconURLVariant(nsIFile* aApplication, nsIVariant** _retval) {
      nsAutoCString fileURLSpec;
      NS_GetURLSpecFromFile(aApplication, fileURLSpec);
      nsAutoCString iconURLSpec;
      iconURLSpec.AssignLiteral("moz-icon://");
      iconURLSpec += fileURLSpec;
      RefPtr writable(new nsVariant());
      writable->SetAsAUTF8String(iconURLSpec);
      writable.forget(_retval);
      return NS_OK;
    }

## Minimal test - lines (349, 360)

path: .spaces[9].metrics.cognitive.average
old: 6.0
new: 2.0
path: .spaces[9].metrics.cognitive.sum
old: 6.0
new: 2.0
path: .spaces[9].metrics.cyclomatic.sum
old: 6.0
new: 3.0
path: .spaces[9].metrics.cyclomatic.average
old: 6.0
new: 3.0
path: .spaces[9].metrics.nexits.sum
old: 1.0
new: 3.0
path: .spaces[9].metrics.nexits.average
old: 1.0
new: 3.0
path: .spaces[9].metrics.loc.cloc
old: 3.0
new: 0.0
path: .spaces[9].metrics.loc.ploc
old: 29.0
new: 10.0
path: .spaces[9].metrics.loc.sloc
old: 34.0
new: 12.0
path: .spaces[9].metrics.loc.lloc
old: 10.0
new: 7.0
path: .spaces[9].metrics.nargs.average
old: 7.0
new: 2.0
path: .spaces[9].metrics.nargs.sum
old: 7.0
new: 2.0
path: .spaces[9].metrics.halstead.time
old: 921.324773899913
new: 193.58024691358025
path: .spaces[9].metrics.halstead.vocabulary
old: 53.0
new: 32.0
path: .spaces[9].metrics.halstead.n1
old: 19.0
new: 14.0
path: .spaces[9].metrics.halstead.N1
old: 91.0
new: 36.0
path: .spaces[9].metrics.halstead.effort
old: 16583.845930198433
new: 3484.4444444444443
path: .spaces[9].metrics.halstead.n2
old: 34.0
new: 18.0
path: .spaces[9].metrics.halstead.level
old: 0.05422647527910686
new: 0.09183673469387754
path: .spaces[9].metrics.halstead.volume
old: 899.2835113664222
new: 320.0
path: .spaces[9].metrics.halstead.estimated_program_length
old: 253.68435935793968
new: 128.36161893476807
path: .spaces[9].metrics.halstead.N2
old: 66.0
new: 28.0
path: .spaces[9].metrics.halstead.bugs
old: 0.21677153262599977
new: 0.07661276001857677
path: .spaces[9].metrics.halstead.difficulty
old: 18.441176470588236
new: 10.88888888888889
path: .spaces[9].metrics.halstead.purity_ratio
old: 1.6158239449550296
new: 2.005650295855751
path: .spaces[9].metrics.halstead.length
old: 157.0
new: 64.0
path: .spaces[9].metrics.mi.mi_visual_studio
old: 45.10213338755627
new: 58.51417724871741
path: .spaces[9].metrics.mi.mi_sei
old: 58.38283886078822
new: 68.959581394903
path: .spaces[9].metrics.mi.mi_original
old: 77.12464809272123
new: 100.05924309530678

### Code

    bool nsMIMEInfoWin::GetLocalHandlerApp(const nsAString& aCommandHandler,
                                           nsCOMPtr& aApp) {
      nsCOMPtr locfile;
      nsresult rv = NS_NewLocalFile(aCommandHandler, true, getter_AddRefs(locfile));
      if (NS_FAILED(rv)) return false;

      aApp = do_CreateInstance("@mozilla.org/uriloader/local-handler-app;1");
      if (!aApp) return false;

      aApp->SetExecutable(locfile);
      return true;
    }

## Minimal test - lines (364, 414)

path: .spaces[10].metrics.nexits.sum
old: 3.0
new: 8.0
path: .spaces[10].metrics.nexits.average
old: 3.0
new: 8.0
path: .spaces[10].metrics.nargs.sum
old: 1.0
new: 3.0
path: .spaces[10].metrics.nargs.average
old: 1.0
new: 3.0
path: .spaces[10].metrics.cyclomatic.average
old: 11.0
new: 10.0
path: .spaces[10].metrics.cyclomatic.sum
old: 11.0
new: 10.0
path: .spaces[10].metrics.loc.sloc
old: 59.0
new: 51.0
path: .spaces[10].metrics.loc.blank
old: 10.0
new: 9.0
path: .spaces[10].metrics.loc.ploc
old: 45.0
new: 38.0
path: .spaces[10].metrics.loc.lloc
old: 22.0
new: 25.0
path: .spaces[10].metrics.cognitive.average
old: 14.0
new: 11.0
path: .spaces[10].metrics.cognitive.sum
old: 14.0
new: 11.0
path: .spaces[10].metrics.mi.mi_sei
old: 37.864199698125304
new: 44.76883674254934
path: .spaces[10].metrics.mi.mi_original
old: 64.33706960158881
new: 68.22830259692935
path: .spaces[10].metrics.mi.mi_visual_studio
old: 37.62401731087065
new: 39.89959216194699
path: .spaces[10].metrics.halstead.vocabulary
old: 70.0
new: 56.0
path: .spaces[10].metrics.halstead.n2
old: 52.0
new: 38.0
path: .spaces[10].metrics.halstead.time
old: 1499.3758580201625
new: 1380.5458075896672
path: .spaces[10].metrics.halstead.level
old: 0.05609492988133765
new: 0.04744069912609239
path: .spaces[10].metrics.halstead.estimated_program_length
old: 371.48151536929834
new: 274.4798955368178
path: .spaces[10].metrics.halstead.bugs
old: 0.2999167752971287
new: 0.283853527931455
path: .spaces[10].metrics.halstead.N2
old: 103.0
new: 89.0
path: .spaces[10].metrics.halstead.effort
old: 26988.765444362925
new: 24849.82453661401
path: .spaces[10].metrics.halstead.purity_ratio
old: 1.5039737464344065
new: 1.3521177120040286
path: .spaces[10].metrics.halstead.length
old: 247.0
new: 203.0
path: .spaces[10].metrics.halstead.difficulty
old: 17.826923076923077
new: 21.07894736842105
path: .spaces[10].metrics.halstead.volume
old: 1513.9329051854068
new: 1178.8930491776937
path: .spaces[10].metrics.halstead.N1
old: 144.0
new: 114.0

### Code

    bool nsMIMEInfoWin::GetAppsVerbCommandHandler(const nsAString& appExeName,
                                                  nsAString& applicationPath,
                                                  bool edit) {
      nsCOMPtr appKey =
          do_CreateInstance("@mozilla.org/windows-registry-key;1");
      if (!appKey) return false;

      // HKEY_CLASSES_ROOT\Applications\iexplore.exe
      nsAutoString applicationsPath;
      applicationsPath.AppendLiteral("Applications\\");
      applicationsPath.Append(appExeName);

      nsresult rv =
          appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, applicationsPath,
                       nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_FAILED(rv)) return false;

      // Check for the NoOpenWith flag, if it exists
      uint32_t value;
      if (NS_SUCCEEDED(appKey->ReadIntValue(u"NoOpenWith"_ns, &value)) &&
          value == 1)
        return false;

      nsAutoString dummy;
      if (NS_SUCCEEDED(appKey->ReadStringValue(u"NoOpenWith"_ns, dummy)))
        return false;

      appKey->Close();

      // HKEY_CLASSES_ROOT\Applications\iexplore.exe\shell\open\command
      applicationsPath.AssignLiteral("Applications\\");
      applicationsPath.Append(appExeName);
      if (!edit)
        applicationsPath.AppendLiteral("\\shell\\open\\command");
      else
        applicationsPath.AppendLiteral("\\shell\\edit\\command");

      rv = appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, applicationsPath,
                        nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_FAILED(rv)) return false;

      nsAutoString appFilesystemCommand;
      if (NS_SUCCEEDED(appKey->ReadStringValue(u""_ns, appFilesystemCommand))) {
        // Expand environment vars, clean up any misc.
        if (!nsLocalFile::CleanupCmdHandlerPath(appFilesystemCommand)) return false;

        applicationPath = appFilesystemCommand;
        return true;
      }
      return false;
    }

## Minimal test - lines (886, 900)

path: .spaces[16].metrics.cyclomatic.sum
old: 18.0
new: 3.0
path: .spaces[16].metrics.cyclomatic.average
old: 18.0
new: 3.0
path: .spaces[16].metrics.halstead.time
old: 2815.3913916412102
new: 195.21886591531168
path: .spaces[16].metrics.halstead.vocabulary
old: 97.0
new: 29.0
path: .spaces[16].metrics.halstead.n2
old: 77.0
new: 15.0
path: .spaces[16].metrics.halstead.purity_ratio
old: 1.5012694605046295
new: 1.8049407716602297
path: .spaces[16].metrics.halstead.difficulty
old: 20.25974025974026
new: 11.666666666666666
path: .spaces[16].metrics.halstead.N1
old: 223.0
new: 37.0
path: .spaces[16].metrics.halstead.effort
old: 50677.04504954178
new: 3513.93958647561
path: .spaces[16].metrics.halstead.level
old: 0.04935897435897437
new: 0.08571428571428572
path: .spaces[16].metrics.halstead.volume
old: 2501.3669671889215
new: 301.19482169790945
path: .spaces[16].metrics.halstead.estimated_program_length
old: 568.9811255312546
new: 111.90632784293425
path: .spaces[16].metrics.halstead.length
old: 379.0
new: 62.0
path: .spaces[16].metrics.halstead.N2
old: 156.0
new: 25.0
path: .spaces[16].metrics.halstead.bugs
old: 0.4564777366220616
new: 0.07704449372655633
path: .spaces[16].metrics.halstead.n1
old: 20.0
new: 14.0
path: .spaces[16].metrics.loc.blank
old: 22.0
new: 0.0
path: .spaces[16].metrics.loc.cloc
old: 17.0
new: 1.0
path: .spaces[16].metrics.loc.lloc
old: 52.0
new: 7.0
path: .spaces[16].metrics.loc.sloc
old: 121.0
new: 15.0
path: .spaces[16].metrics.loc.ploc
old: 82.0
new: 14.0
path: .spaces[16].metrics.nexits.average
old: 5.0
new: 2.0
path: .spaces[16].metrics.nexits.sum
old: 5.0
new: 2.0
path: .spaces[16].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[16].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[16].metrics.cognitive.sum
old: 25.0
new: 3.0
path: .spaces[16].metrics.cognitive.average
old: 25.0
new: 3.0
path: .spaces[16].metrics.mi.mi_original
old: 48.480311390181186
new: 96.75924876373654
path: .spaces[16].metrics.mi.mi_sei
old: 23.503870058602004
new: 83.66961305321745
path: .spaces[16].metrics.mi.mi_visual_studio
old: 28.351059292503617
new: 56.58435600218511

### Code

    nsMIMEInfoWin::IsCurrentAppOSDefault(bool* _retval) {
      *_retval = false;
      if (mDefaultApplication) {
        // Determine if the default executable is our executable.
        nsCOMPtr ourBinary;
        XRE_GetBinaryPath(getter_AddRefs(ourBinary));
        bool isSame = false;
        nsresult rv = mDefaultApplication->Equals(ourBinary, &isSame);
        if (NS_FAILED(rv)) {
          return rv;
        }
        *_retval = isSame;
      }
      return NS_OK;
    }

## Minimal test - lines (511, 539)

path: .spaces[12].metrics.loc.lloc
old: 3.0
new: 13.0
path: .spaces[12].metrics.loc.sloc
old: 9.0
new: 29.0
path: .spaces[12].metrics.loc.blank
old: 0.0
new: 5.0
path: .spaces[12].metrics.loc.ploc
old: 9.0
new: 22.0
path: .spaces[12].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[12].metrics.halstead.n2
old: 10.0
new: 29.0
path: .spaces[12].metrics.halstead.estimated_program_length
old: 86.52224985768008
new: 204.88144885869957
path: .spaces[12].metrics.halstead.difficulty
old: 9.1
new: 13.241379310344827
path: .spaces[12].metrics.halstead.length
old: 37.0
new: 113.0
path: .spaces[12].metrics.halstead.volume
old: 169.64361252668277
new: 620.5793998852532
path: .spaces[12].metrics.halstead.n1
old: 14.0
new: 16.0
path: .spaces[12].metrics.halstead.purity_ratio
old: 2.338439185342705
new: 1.813110166891147
path: .spaces[12].metrics.halstead.effort
old: 1543.756873992813
new: 8217.327226066802
path: .spaces[12].metrics.halstead.time
old: 85.7642707773785
new: 456.5181792259334
path: .spaces[12].metrics.halstead.bugs
old: 0.04452439376328848
new: 0.1357372771083021
path: .spaces[12].metrics.halstead.level
old: 0.10989010989010987
new: 0.07552083333333333
path: .spaces[12].metrics.halstead.vocabulary
old: 24.0
new: 45.0
path: .spaces[12].metrics.halstead.N2
old: 13.0
new: 48.0
path: .spaces[12].metrics.halstead.N1
old: 24.0
new: 65.0
path: .spaces[12].metrics.cognitive.average
old: 1.0
new: 7.0
path: .spaces[12].metrics.cognitive.sum
old: 1.0
new: 7.0
path: .spaces[12].metrics.nargs.average
old: 0.0
new: 3.0
path: .spaces[12].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[12].metrics.mi.mi_original
old: 108.24972268106455
new: 81.63040905472553
path: .spaces[12].metrics.mi.mi_visual_studio
old: 63.30393139243542
new: 47.737081318552946
path: .spaces[12].metrics.mi.mi_sei
old: 80.67412581637358
new: 62.46322838904779
path: .spaces[12].metrics.nexits.sum
old: 1.0
new: 5.0
path: .spaces[12].metrics.nexits.average
old: 1.0
new: 5.0
path: .spaces[12].metrics.cyclomatic.sum
old: 2.0
new: 6.0
path: .spaces[12].metrics.cyclomatic.average
old: 2.0
new: 6.0

### Code

    bool nsMIMEInfoWin::GetProgIDVerbCommandHandler(const nsAString& appProgIDName,
                                                    nsAString& applicationPath,
                                                    bool edit) {
      nsCOMPtr appKey =
          do_CreateInstance("@mozilla.org/windows-registry-key;1");
      if (!appKey) return false;

      nsAutoString appProgId(appProgIDName);

      // HKEY_CLASSES_ROOT\Windows.XPSReachViewer\shell\open\command
      if (!edit)
        appProgId.AppendLiteral("\\shell\\open\\command");
      else
        appProgId.AppendLiteral("\\shell\\edit\\command");

      nsresult rv = appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, appProgId,
                                 nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_FAILED(rv)) return false;

      nsAutoString appFilesystemCommand;
      if (NS_SUCCEEDED(appKey->ReadStringValue(u""_ns, appFilesystemCommand))) {
        // Expand environment vars, clean up any misc.
        if (!nsLocalFile::CleanupCmdHandlerPath(appFilesystemCommand)) return false;

        applicationPath = appFilesystemCommand;
        return true;
      }
      return false;
    }

## Minimal test - lines (245, 266)

path: .spaces[7].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[7].metrics.nargs.average
old: 1.0
new: 2.0
path: .spaces[7].metrics.cognitive.average
old: 4.0
new: 3.0
path: .spaces[7].metrics.cognitive.sum
old: 4.0
new: 3.0
path: .spaces[7].metrics.halstead.vocabulary
old: 43.0
new: 39.0
path: .spaces[7].metrics.halstead.bugs
old: 0.10511103882122114
new: 0.15396950525509487
path: .spaces[7].metrics.halstead.n1
old: 19.0
new: 16.0
path: .spaces[7].metrics.halstead.N2
old: 33.0
new: 50.0
path: .spaces[7].metrics.halstead.length
old: 79.0
new: 108.0
path: .spaces[7].metrics.halstead.volume
old: 428.67491562146574
new: 570.8234396371229
path: .spaces[7].metrics.halstead.n2
old: 24.0
new: 23.0
path: .spaces[7].metrics.halstead.level
old: 0.07655502392344497
new: 0.0575
path: .spaces[7].metrics.halstead.difficulty
old: 13.0625
new: 17.391304347826086
path: .spaces[7].metrics.halstead.N1
old: 46.0
new: 58.0
path: .spaces[7].metrics.halstead.estimated_program_length
old: 190.74972277273588
new: 168.0419249893113
path: .spaces[7].metrics.halstead.effort
old: 5599.566085305396
new: 9927.364167602136
path: .spaces[7].metrics.halstead.purity_ratio
old: 2.4145534528194417
new: 1.5559437499010305
path: .spaces[7].metrics.halstead.time
old: 311.08700473918867
new: 551.520231533452
path: .spaces[7].metrics.loc.blank
old: 2.0
new: 3.0
path: .spaces[7].metrics.loc.cloc
old: 4.0
new: 0.0
path: .spaces[7].metrics.loc.lloc
old: 6.0
new: 10.0
path: .spaces[7].metrics.loc.ploc
old: 16.0
new: 19.0
path: .spaces[7].metrics.mi.mi_sei
old: 82.81843727859095
new: 49.99132378980886
path: .spaces[7].metrics.mi.mi_visual_studio
old: 51.61372993427096
new: 50.742863461554755
path: .spaces[7].metrics.mi.mi_original
old: 88.25947818760335
new: 86.77029651925864
path: .spaces[7].metrics.nexits.sum
old: 3.0
new: 1.0
path: .spaces[7].metrics.nexits.average
old: 3.0
new: 1.0

### Code

    nsMIMEInfoWin::GetProperty(const nsAString& aName, nsIVariant** _retval) {
      nsresult rv;
      if (mDefaultApplication &&
          aName.EqualsLiteral(PROPERTY_DEFAULT_APP_ICON_URL)) {
        rv = GetIconURLVariant(mDefaultApplication, _retval);
        NS_ENSURE_SUCCESS(rv, rv);
      } else if (mPreferredApplication &&
                 aName.EqualsLiteral(PROPERTY_CUSTOM_APP_ICON_URL)) {
        nsCOMPtr localHandler =
            do_QueryInterface(mPreferredApplication, &rv);
        NS_ENSURE_SUCCESS(rv, rv);

        nsCOMPtr executable;
        rv = localHandler->GetExecutable(getter_AddRefs(executable));
        NS_ENSURE_SUCCESS(rv, rv);

        rv = GetIconURLVariant(executable, _retval);
        NS_ENSURE_SUCCESS(rv, rv);
      }

      return NS_OK;
    }

## Minimal test - lines (43, 86)

path: .spaces[2].metrics.halstead.n1
old: 9.0
new: 17.0
path: .spaces[2].metrics.halstead.N2
old: 8.0
new: 65.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 2.4090404733692017
new: 1.6816063707445985
path: .spaces[2].metrics.halstead.time
old: 22.857142857142858
new: 742.3314194046566
path: .spaces[2].metrics.halstead.effort
old: 411.42857142857144
new: 13361.965549283816
path: .spaces[2].metrics.halstead.volume
old: 80.0
new: 870.6439090936062
path: .spaces[2].metrics.halstead.estimated_program_length
old: 48.18080946738404
new: 255.60416835317895
path: .spaces[2].metrics.halstead.N1
old: 12.0
new: 87.0
path: .spaces[2].metrics.halstead.vocabulary
old: 16.0
new: 53.0
path: .spaces[2].metrics.halstead.bugs
old: 0.018439184525994783
new: 0.1876977113041125
path: .spaces[2].metrics.halstead.level
old: 0.1944444444444444
new: 0.06515837104072399
path: .spaces[2].metrics.halstead.n2
old: 7.0
new: 36.0
path: .spaces[2].metrics.halstead.difficulty
old: 5.142857142857143
new: 15.34722222222222
path: .spaces[2].metrics.halstead.length
old: 20.0
new: 152.0
path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 5.0
path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 5.0
path: .spaces[2].metrics.cyclomatic.average
old: 2.0
new: 6.0
path: .spaces[2].metrics.cyclomatic.sum
old: 2.0
new: 6.0
path: .spaces[2].metrics.mi.mi_original
old: 125.2954928495536
new: 73.11611600143777
path: .spaces[2].metrics.mi.mi_visual_studio
old: 73.27221804067462
new: 42.75796257394022
path: .spaces[2].metrics.mi.mi_sei
old: 105.26597390658571
new: 64.05510734277742
path: .spaces[2].metrics.loc.lloc
old: 1.0
new: 11.0
path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 10.0
path: .spaces[2].metrics.loc.ploc
old: 4.0
new: 28.0
path: .spaces[2].metrics.loc.blank
old: 0.0
new: 6.0
path: .spaces[2].metrics.loc.sloc
old: 4.0
new: 44.0
path: .spaces[2].metrics.nargs.average
old: 0.0
new: 3.0
path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 4.0
path: .spaces[2].metrics.nexits.average
old: 1.0
new: 4.0

### Code

    nsresult nsMIMEInfoWin::ShellExecuteWithIFile(nsIFile* aExecutable, int aArgc,
                                                  const wchar_t** aArgv) {
      nsresult rv;

      NS_ASSERTION(aArgc >= 1, "aArgc must be at least 1");

      nsAutoString execPath;
      rv = aExecutable->GetTarget(execPath);
      if (NS_FAILED(rv) || execPath.IsEmpty()) {
        rv = aExecutable->GetPath(execPath);
      }
      if (NS_FAILED(rv)) {
        return rv;
      }

      auto assembledArgs = mozilla::MakeCommandLine(aArgc, aArgv);
      if (!assembledArgs) {
        return NS_ERROR_FILE_EXECUTION_FAILED;
      }

      _bstr_t execPathBStr(execPath.get());
      // Pass VT_ERROR/DISP_E_PARAMNOTFOUND to omit an optional RPC parameter
      // to execute a file with the default verb.
      _variant_t verbDefault(DISP_E_PARAMNOTFOUND, VT_ERROR);
      _variant_t workingDir;
      _variant_t showCmd(SW_SHOWNORMAL);

      // Ask Explorer to ShellExecute on our behalf, as some applications such as
      // Skype for Business do not start correctly when inheriting our process's
      // migitation policies.
      // It does not work in a special environment such as Citrix.  In such a case
      // we fall back to launching an application as a child process.  We need to
      // find a way to handle the combination of these interop issues.
      mozilla::LauncherVoidResult shellExecuteOk = mozilla::ShellExecuteByExplorer(
          execPathBStr, assembledArgs.get(), verbDefault, workingDir, showCmd);
      if (shellExecuteOk.isErr()) {
        // No need to pass assembledArgs to LaunchWithIProcess.  aArgv will be
        // processed in nsProcess::RunProcess.
        return LaunchWithIProcess(aExecutable, aArgc,
                                  reinterpret_cast(aArgv));
      }

      return NS_OK;
    }

## Minimal test - lines (270, 346)

path: .spaces[8].metrics.loc.ploc
old: 35.0
new: 41.0
path: .spaces[8].metrics.loc.lloc
old: 14.0
new: 16.0
path: .spaces[8].metrics.loc.sloc
old: 64.0
new: 77.0
path: .spaces[8].metrics.loc.blank
old: 5.0
new: 11.0
path: .spaces[8].metrics.loc.cloc
old: 24.0
new: 25.0
path: .spaces[8].metrics.nargs.sum
old: 3.0
new: 1.0
path: .spaces[8].metrics.nargs.average
old: 3.0
new: 1.0
path: .spaces[8].metrics.cyclomatic.average
old: 10.0
new: 7.0
path: .spaces[8].metrics.cyclomatic.sum
old: 10.0
new: 7.0
path: .spaces[8].metrics.cognitive.sum
old: 12.0
new: 10.0
path: .spaces[8].metrics.cognitive.average
old: 12.0
new: 10.0
path: .spaces[8].metrics.mi.mi_sei
old: 58.37212173664484
new: 52.774223916744255
path: .spaces[8].metrics.mi.mi_visual_studio
old: 37.46332027483367
new: 36.13218659922112
path: .spaces[8].metrics.mi.mi_original
old: 64.06227766996558
new: 61.78603908466812
path: .spaces[8].metrics.nexits.average
old: 1.0
new: 3.0
path: .spaces[8].metrics.nexits.sum
old: 1.0
new: 3.0
path: .spaces[8].metrics.halstead.estimated_program_length
old: 334.7944727340507
new: 393.0334342698179
path: .spaces[8].metrics.halstead.purity_ratio
old: 1.5571835941118637
new: 1.889583818604894
path: .spaces[8].metrics.halstead.vocabulary
old: 65.0
new: 73.0
path: .spaces[8].metrics.halstead.n2
old: 46.0
new: 55.0
path: .spaces[8].metrics.halstead.length
old: 215.0
new: 208.0
path: .spaces[8].metrics.halstead.bugs
old: 0.27991146034637193
new: 0.24399353030525883
path: .spaces[8].metrics.halstead.effort
old: 24333.96629321883
new: 19803.837235945433
path: .spaces[8].metrics.halstead.N2
old: 91.0
new: 94.0
path: .spaces[8].metrics.halstead.N1
old: 124.0
new: 114.0
path: .spaces[8].metrics.halstead.difficulty
old: 18.793478260869566
new: 15.38181818181818
path: .spaces[8].metrics.halstead.level
old: 0.05320994794679005
new: 0.06501182033096928
path: .spaces[8].metrics.halstead.n1
old: 19.0
new: 18.0
path: .spaces[8].metrics.halstead.time
old: 1351.887016289935
new: 1100.2131797747463
path: .spaces[8].metrics.halstead.volume
old: 1294.8090798011176
new: 1287.4835082470436

### Code

    nsresult nsMIMEInfoWin::LoadUriInternal(nsIURI* aURL) {
      nsresult rv = NS_OK;

      // 1. Find the default app for this protocol
      // 2. Set up the command line
      // 3. Launch the app.

      // For now, we'll just cheat essentially, check for the command line
      // then just call ShellExecute()!

      if (aURL) {
        // extract the url spec from the url
        nsAutoCString urlSpec;
        aURL->GetAsciiSpec(urlSpec);

        // Unescape non-ASCII characters in the URL
        nsAutoString utf16Spec;

        nsCOMPtr textToSubURI =
            do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
        NS_ENSURE_SUCCESS(rv, rv);

        if (NS_FAILED(textToSubURI->UnEscapeNonAsciiURI("UTF-8"_ns, urlSpec,
                                                        utf16Spec))) {
          CopyASCIItoUTF16(urlSpec, utf16Spec);
        }

        // Ask the shell/urlmon to parse |utf16Spec| to avoid malformed URLs.
        // Failure is indicative of a potential security issue so we should
        // bail out if so.
        LauncherResult<_bstr_t> validatedUri = UrlmonValidateUri(utf16Spec.get());
        if (validatedUri.isErr()) {
          return NS_ERROR_FAILURE;
        }

        _variant_t args;
        _variant_t verb(L"open");
        _variant_t workingDir;
        _variant_t showCmd(SW_SHOWNORMAL);

        // To open a uri, we first try ShellExecuteByExplorer, which starts a new
        // process as a child process of explorer.exe, because applications may not
        // support the mitigation policies inherited from our process.  If it fails,
        // we fall back to ShellExecuteExW.
        //
        // For Thunderbird, however, there is a known issue that
        // ShellExecuteByExplorer succeeds but explorer.exe shows an error popup
        // if a uri to open includes credentials.  This does not happen in Firefox
        // because Firefox does not have to launch a process to open a uri.
        //
        // Since Thunderbird does not use mitigation policies which could cause
        // compatibility issues, we get no benefit from using
        // ShellExecuteByExplorer.  Thus we skip it and go straight to
        // ShellExecuteExW for Thunderbird.
    #ifndef MOZ_THUNDERBIRD
        mozilla::LauncherVoidResult shellExecuteOk =
            mozilla::ShellExecuteByExplorer(validatedUri.inspect(), args, verb,
                                            workingDir, showCmd);
        if (shellExecuteOk.isOk()) {
          return NS_OK;
        }
    #endif  // MOZ_THUNDERBIRD

        SHELLEXECUTEINFOW sinfo = {sizeof(sinfo)};
        sinfo.fMask = SEE_MASK_NOASYNC;
        sinfo.lpVerb = V_BSTR(&verb);
        sinfo.nShow = showCmd;
        sinfo.lpFile = validatedUri.inspect();

        BOOL result = ShellExecuteExW(&sinfo);
        if (!result || reinterpret_cast(sinfo.hInstApp) < 32) {
          rv = NS_ERROR_FAILURE;
        }
      }

      return rv;
    }

## Minimal test - lines (210, 216)

path: .spaces[4].metrics.halstead.N2
old: 33.0
new: 6.0
path: .spaces[4].metrics.halstead.volume
old: 442.8035360784607
new: 74.23092131656186
path: .spaces[4].metrics.halstead.n1
old: 14.0
new: 10.0
path: .spaces[4].metrics.halstead.n2
old: 23.0
new: 5.0
path: .spaces[4].metrics.halstead.difficulty
old: 10.043478260869565
new: 6.0
path: .spaces[4].metrics.halstead.estimated_program_length
old: 157.34489389811776
new: 44.82892142331043
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.8511163988013857
new: 2.3594169170163384
path: .spaces[4].metrics.halstead.vocabulary
old: 37.0
new: 15.0
path: .spaces[4].metrics.halstead.effort
old: 4447.287688440192
new: 445.38552789937114
path: .spaces[4].metrics.halstead.length
old: 85.0
new: 19.0
path: .spaces[4].metrics.halstead.N1
old: 52.0
new: 13.0
path: .spaces[4].metrics.halstead.level
old: 0.09956709956709955
new: 0.16666666666666666
path: .spaces[4].metrics.halstead.bugs
old: 0.09014512143294157
new: 0.019440293291897705
path: .spaces[4].metrics.halstead.time
old: 247.0715382466773
new: 24.74364043885395
path: .spaces[4].metrics.cyclomatic.average
old: 6.0
new: 1.0
path: .spaces[4].metrics.cyclomatic.sum
old: 6.0
new: 1.0
path: .spaces[4].metrics.nexits.sum
old: 4.0
new: 1.0
path: .spaces[4].metrics.nexits.average
old: 4.0
new: 1.0
path: .spaces[4].metrics.loc.lloc
old: 7.0
new: 2.0
path: .spaces[4].metrics.loc.ploc
old: 16.0
new: 4.0
path: .spaces[4].metrics.loc.blank
old: 3.0
new: 0.0
path: .spaces[4].metrics.loc.cloc
old: 7.0
new: 3.0
path: .spaces[4].metrics.loc.sloc
old: 26.0
new: 7.0
path: .spaces[4].metrics.cognitive.average
old: 5.0
new: 0.0
path: .spaces[4].metrics.cognitive.sum
old: 5.0
new: 0.0
path: .spaces[4].metrics.mi.mi_sei
old: 83.76335903266619
new: 135.43083450338628
path: .spaces[4].metrics.mi.mi_visual_studio
old: 49.79799994977495
new: 68.33269910132546
path: .spaces[4].metrics.mi.mi_original
old: 85.15457991411517
new: 116.84891546326654
path: .spaces[4].metrics.nargs.average
old: 2.0
new: 1.0
path: .spaces[4].metrics.nargs.sum
old: 2.0
new: 1.0

### Code

    nsMIMEInfoWin::GetHasDefaultHandler(bool* _retval) {
      // We have a default application if we have a description
      // We can ShellExecute anything; however, callers are probably interested if
      // there is really an application associated with this type of file
      *_retval = !mDefaultAppDescription.IsEmpty();
      return NS_OK;
    }

## Minimal test - lines (89, 207)

path: .spaces[3].metrics.halstead.time
old: 350.3901212709177
new: 4650.300724895228
path: .spaces[3].metrics.halstead.n1
old: 16.0
new: 27.0
path: .spaces[3].metrics.halstead.difficulty
old: 16.533333333333335
new: 25.897959183673468
path: .spaces[3].metrics.halstead.length
old: 77.0
new: 464.0
path: .spaces[3].metrics.halstead.effort
old: 6307.022182876518
new: 83705.4130481141
path: .spaces[3].metrics.halstead.level
old: 0.06048387096774193
new: 0.038613081166272656
path: .spaces[3].metrics.halstead.bugs
old: 0.1137876122773464
new: 0.6378439508414062
path: .spaces[3].metrics.halstead.N1
old: 46.0
new: 276.0
path: .spaces[3].metrics.halstead.N2
old: 31.0
new: 188.0
path: .spaces[3].metrics.halstead.n2
old: 15.0
new: 98.0
path: .spaces[3].metrics.halstead.volume
old: 381.4731158997894
new: 3232.1239080832083
path: .spaces[3].metrics.halstead.estimated_program_length
old: 122.60335893412778
new: 776.623527281704
path: .spaces[3].metrics.halstead.vocabulary
old: 31.0
new: 125.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.5922514147289322
new: 1.6737576019002245
path: .spaces[3].metrics.cognitive.average
old: 6.0
new: 41.0
path: .spaces[3].metrics.cognitive.sum
old: 6.0
new: 41.0
path: .spaces[3].metrics.nargs.average
old: 2.0
new: 1.0
path: .spaces[3].metrics.nargs.sum
old: 2.0
new: 1.0
path: .spaces[3].metrics.nexits.average
old: 0.0
new: 18.0
path: .spaces[3].metrics.nexits.sum
old: 0.0
new: 18.0
path: .spaces[3].metrics.loc.blank
old: 0.0
new: 13.0
path: .spaces[3].metrics.loc.sloc
old: 13.0
new: 119.0
path: .spaces[3].metrics.loc.cloc
old: 2.0
new: 11.0
path: .spaces[3].metrics.loc.ploc
old: 11.0
new: 95.0
path: .spaces[3].metrics.loc.lloc
old: 5.0
new: 65.0
path: .spaces[3].metrics.cyclomatic.sum
old: 5.0
new: 27.0
path: .spaces[3].metrics.cyclomatic.average
old: 5.0
new: 27.0
path: .spaces[3].metrics.mi.mi_sei
old: 93.8573246374556
new: 15.16021233913498
path: .spaces[3].metrics.mi.mi_original
old: 97.38881043947632
new: 45.34754667621689
path: .spaces[3].metrics.mi.mi_visual_studio
old: 56.95252072483995
new: 26.51903314398649

### Code

    nsMIMEInfoWin::LaunchWithFile(nsIFile* aFile) {
      nsresult rv;

      // it doesn't make any sense to call this on protocol handlers
      NS_ASSERTION(mClass == eMIMEInfo,
                   "nsMIMEInfoBase should have mClass == eMIMEInfo");

      if (mPreferredAction == useSystemDefault) {
        if (mDefaultApplication &&
            StaticPrefs::browser_pdf_launchDefaultEdgeAsApp()) {
          // Since Edgium is the default handler for PDF and other kinds of files,
          // if we're using the OS default and it's Edgium prefer its app mode so it
          // operates as a viewer (without browser toolbars). Bug 1632277.
          nsAutoCString defaultAppExecutable;
          rv = mDefaultApplication->GetNativeLeafName(defaultAppExecutable);
          if (NS_SUCCEEDED(rv) &&
              defaultAppExecutable.LowerCaseEqualsLiteral("msedge.exe")) {
            nsAutoString path;
            rv = aFile->GetPath(path);
            if (NS_SUCCEEDED(rv)) {
              // If the --app flag doesn't work we'll want to fallback to a
              // regular path. Send two args so we call `msedge.exe --app={path}
              // {path}`.
              nsAutoString appArg;
              appArg.AppendLiteral("--app=");
              appArg.Append(path);
              const wchar_t* argv[] = {appArg.get(), path.get()};

              return ShellExecuteWithIFile(mDefaultApplication,
                                           mozilla::ArrayLength(argv), argv);
            }
          }
        }
        return LaunchDefaultWithFile(aFile);
      }

      if (mPreferredAction == useHelperApp) {
        if (!mPreferredApplication) return NS_ERROR_FILE_NOT_FOUND;

        // at the moment, we only know how to hand files off to local handlers
        nsCOMPtr localHandler =
            do_QueryInterface(mPreferredApplication, &rv);
        NS_ENSURE_SUCCESS(rv, rv);

        nsCOMPtr executable;
        rv = localHandler->GetExecutable(getter_AddRefs(executable));
        NS_ENSURE_SUCCESS(rv, rv);

        // Deal with local dll based handlers
        nsCString filename;
        executable->GetNativeLeafName(filename);
        if (filename.Length() > 4) {
          nsCString extension(Substring(filename, filename.Length() - 4, 4));

          if (extension.LowerCaseEqualsLiteral(".dll")) {
            nsAutoString args;

            // executable is rundll32, everything else is a list of parameters,
            // including the dll handler.
            if (!GetDllLaunchInfo(executable, aFile, args, false))
              return NS_ERROR_INVALID_ARG;

            WCHAR rundll32Path[MAX_PATH + sizeof(RUNDLL32_EXE) / sizeof(WCHAR) +
                               1] = {L'\0'};
            if (!GetSystemDirectoryW(rundll32Path, MAX_PATH)) {
              return NS_ERROR_FILE_NOT_FOUND;
            }
            lstrcatW(rundll32Path, RUNDLL32_EXE);

            SHELLEXECUTEINFOW seinfo;
            memset(&seinfo, 0, sizeof(seinfo));
            seinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
            seinfo.fMask = 0;
            seinfo.hwnd = nullptr;
            seinfo.lpVerb = nullptr;
            seinfo.lpFile = rundll32Path;
            seinfo.lpParameters = args.get();
            seinfo.lpDirectory = nullptr;
            seinfo.nShow = SW_SHOWNORMAL;
            if (ShellExecuteExW(&seinfo)) return NS_OK;

            switch ((LONG_PTR)seinfo.hInstApp) {
              case 0:
              case SE_ERR_OOM:
                return NS_ERROR_OUT_OF_MEMORY;
              case SE_ERR_ACCESSDENIED:
                return NS_ERROR_FILE_ACCESS_DENIED;
              case SE_ERR_ASSOCINCOMPLETE:
              case SE_ERR_NOASSOC:
                return NS_ERROR_UNEXPECTED;
              case SE_ERR_DDEBUSY:
              case SE_ERR_DDEFAIL:
              case SE_ERR_DDETIMEOUT:
                return NS_ERROR_NOT_AVAILABLE;
              case SE_ERR_DLLNOTFOUND:
                return NS_ERROR_FAILURE;
              case SE_ERR_SHARE:
                return NS_ERROR_FILE_IS_LOCKED;
              default:
                switch (GetLastError()) {
                  case ERROR_FILE_NOT_FOUND:
                    return NS_ERROR_FILE_NOT_FOUND;
                  case ERROR_PATH_NOT_FOUND:
                    return NS_ERROR_FILE_UNRECOGNIZED_PATH;
                  case ERROR_BAD_FORMAT:
                    return NS_ERROR_FILE_CORRUPTED;
                }
            }
            return NS_ERROR_FILE_EXECUTION_FAILED;
          }
        }
        nsAutoString path;
        aFile->GetPath(path);
        const wchar_t* argv[] = {path.get()};
        return ShellExecuteWithIFile(executable, mozilla::ArrayLength(argv), argv);
      }

      return NS_ERROR_INVALID_ARG;
    }

## Minimal test - lines (420, 507)

path: .spaces[11].metrics.halstead.n1
old: 14.0
new: 22.0
path: .spaces[11].metrics.halstead.time
old: 142.64058356400875
new: 3783.8203890394543
path: .spaces[11].metrics.halstead.estimated_program_length
old: 117.30296890880646
new: 482.1074956100205
path: .spaces[11].metrics.halstead.effort
old: 2567.5305041521574
new: 68108.76700271018
path: .spaces[11].metrics.halstead.volume
old: 255.15831097164295
new: 2416.275547767989
path: .spaces[11].metrics.halstead.N1
old: 29.0
new: 212.0
path: .spaces[11].metrics.halstead.n2
old: 16.0
new: 64.0
path: .spaces[11].metrics.halstead.purity_ratio
old: 2.255826325169355
new: 1.2822007861968632
path: .spaces[11].metrics.halstead.difficulty
old: 10.0625
new: 28.1875
path: .spaces[11].metrics.halstead.level
old: 0.09937888198757765
new: 0.03547671840354767
path: .spaces[11].metrics.halstead.bugs
old: 0.06250131478439644
new: 0.555922293927617
path: .spaces[11].metrics.halstead.vocabulary
old: 30.0
new: 86.0
path: .spaces[11].metrics.halstead.N2
old: 23.0
new: 164.0
path: .spaces[11].metrics.halstead.length
old: 52.0
new: 376.0
path: .spaces[11].metrics.nexits.average
old: 0.0
new: 12.0
path: .spaces[11].metrics.nexits.sum
old: 0.0
new: 12.0
path: .spaces[11].metrics.cognitive.average
old: 0.0
new: 22.0
path: .spaces[11].metrics.cognitive.sum
old: 0.0
new: 22.0
path: .spaces[11].metrics.cyclomatic.sum
old: 2.0
new: 16.0
path: .spaces[11].metrics.cyclomatic.average
old: 2.0
new: 16.0
path: .spaces[11].metrics.mi.mi_original
old: 104.42032375820035
new: 54.27923406579792
path: .spaces[11].metrics.mi.mi_sei
old: 75.14947098077185
new: 28.007309768643132
path: .spaces[11].metrics.mi.mi_visual_studio
old: 61.06451681766103
new: 31.74224214374147
path: .spaces[11].metrics.nargs.sum
old: 2.0
new: 4.0
path: .spaces[11].metrics.nargs.average
old: 2.0
new: 4.0
path: .spaces[11].metrics.loc.lloc
old: 5.0
new: 42.0
path: .spaces[11].metrics.loc.blank
old: 1.0
new: 15.0
path: .spaces[11].metrics.loc.ploc
old: 9.0
new: 64.0
path: .spaces[11].metrics.loc.cloc
old: 0.0
new: 9.0
path: .spaces[11].metrics.loc.sloc
old: 10.0
new: 88.0

### Code

    bool nsMIMEInfoWin::GetDllLaunchInfo(nsIFile* aDll, nsIFile* aFile,
                                         nsAString& args, bool edit) {
      if (!aDll || !aFile) return false;

      nsString appExeName;
      aDll->GetLeafName(appExeName);

      nsCOMPtr appKey =
          do_CreateInstance("@mozilla.org/windows-registry-key;1");
      if (!appKey) return false;

      // HKEY_CLASSES_ROOT\Applications\iexplore.exe
      nsAutoString applicationsPath;
      applicationsPath.AppendLiteral("Applications\\");
      applicationsPath.Append(appExeName);

      nsresult rv =
          appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, applicationsPath,
                       nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_FAILED(rv)) return false;

      // Check for the NoOpenWith flag, if it exists
      uint32_t value;
      rv = appKey->ReadIntValue(u"NoOpenWith"_ns, &value);
      if (NS_SUCCEEDED(rv) && value == 1) return false;

      nsAutoString dummy;
      if (NS_SUCCEEDED(appKey->ReadStringValue(u"NoOpenWith"_ns, dummy)))
        return false;

      appKey->Close();

      // HKEY_CLASSES_ROOT\Applications\iexplore.exe\shell\open\command
      applicationsPath.AssignLiteral("Applications\\");
      applicationsPath.Append(appExeName);
      if (!edit)
        applicationsPath.AppendLiteral("\\shell\\open\\command");
      else
        applicationsPath.AppendLiteral("\\shell\\edit\\command");

      rv = appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, applicationsPath,
                        nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if (NS_FAILED(rv)) return false;

      nsAutoString appFilesystemCommand;
      if (NS_SUCCEEDED(appKey->ReadStringValue(u""_ns, appFilesystemCommand))) {
        // Replace embedded environment variables.
        uint32_t bufLength =
            ::ExpandEnvironmentStringsW(appFilesystemCommand.get(), nullptr, 0);
        if (bufLength == 0)  // Error
          return false;

        auto destination = mozilla::MakeUniqueFallible(bufLength);
        if (!destination) return false;
        if (!::ExpandEnvironmentStringsW(appFilesystemCommand.get(),
                                         destination.get(), bufLength))
          return false;

        appFilesystemCommand.Assign(destination.get());

        // C:\Windows\System32\rundll32.exe "C:\Program Files\Windows
        // Photo Gallery\PhotoViewer.dll", ImageView_Fullscreen %1
        nsAutoString params;
        constexpr auto rundllSegment = u"rundll32.exe "_ns;
        int32_t index = appFilesystemCommand.Find(rundllSegment);
        if (index > kNotFound) {
          params.Append(
              Substring(appFilesystemCommand, index + rundllSegment.Length()));
        } else {
          params.Append(appFilesystemCommand);
        }

        // check to make sure we have a %1 and fill it
        constexpr auto percentOneParam = u"%1"_ns;
        index = params.Find(percentOneParam);
        if (index == kNotFound)  // no parameter
          return false;

        nsString target;
        aFile->GetTarget(target);
        params.Replace(index, 2, target);

        args = params;

        return true;
      }
      return false;
    }

## Minimal test - lines (543, 563)

path: .spaces[13].metrics.cognitive.average
old: 3.0
new: 5.0
path: .spaces[13].metrics.cognitive.sum
old: 3.0
new: 5.0
path: .spaces[13].metrics.nargs.sum
old: 4.0
new: 3.0
path: .spaces[13].metrics.nargs.average
old: 4.0
new: 3.0
path: .spaces[13].metrics.cyclomatic.average
old: 4.0
new: 5.0
path: .spaces[13].metrics.cyclomatic.sum
old: 4.0
new: 5.0
path: .spaces[13].metrics.halstead.level
old: 0.07581699346405228
new: 0.06220095693779904
path: .spaces[13].metrics.halstead.length
old: 111.0
new: 103.0
path: .spaces[13].metrics.halstead.n1
old: 15.0
new: 19.0
path: .spaces[13].metrics.halstead.time
old: 444.04945967105954
new: 505.22701540465346
path: .spaces[13].metrics.halstead.N2
old: 51.0
new: 44.0
path: .spaces[13].metrics.halstead.N1
old: 60.0
new: 59.0
path: .spaces[13].metrics.halstead.purity_ratio
old: 1.7971604305660125
new: 1.9701170429815191
path: .spaces[13].metrics.halstead.effort
old: 7992.890274079072
new: 9094.086277283765
path: .spaces[13].metrics.halstead.volume
old: 605.99690966874
new: 565.6608689219565
path: .spaces[13].metrics.halstead.vocabulary
old: 44.0
new: 45.0
path: .spaces[13].metrics.halstead.n2
old: 29.0
new: 26.0
path: .spaces[13].metrics.halstead.difficulty
old: 13.189655172413794
new: 16.076923076923077
path: .spaces[13].metrics.halstead.bugs
old: 0.13325432467305937
new: 0.1452283685615449
path: .spaces[13].metrics.halstead.estimated_program_length
old: 199.48480779282735
new: 202.9220554270965
path: .spaces[13].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[13].metrics.loc.lloc
old: 16.0
new: 8.0
path: .spaces[13].metrics.loc.ploc
old: 25.0
new: 16.0
path: .spaces[13].metrics.loc.sloc
old: 29.0
new: 21.0
path: .spaces[13].metrics.loc.blank
old: 4.0
new: 3.0
path: .spaces[13].metrics.mi.mi_sei
old: 43.31624142191714
new: 74.15100401946455
path: .spaces[13].metrics.mi.mi_original
old: 82.21405814442028
new: 87.571163927897
path: .spaces[13].metrics.mi.mi_visual_studio
old: 48.078396575684366
new: 51.21120697537836

### Code

    void nsMIMEInfoWin::ProcessPath(nsCOMPtr& appList,
                                    nsTArray& trackList,
                                    const nsAString& appFilesystemCommand) {
      nsAutoString lower(appFilesystemCommand);
      ToLowerCase(lower);

      // Don't include firefox.exe in the list
      WCHAR exe[MAX_PATH + 1];
      uint32_t len = GetModuleFileNameW(nullptr, exe, MAX_PATH);
      if (len < MAX_PATH && len != 0) {
        int32_t index = lower.Find(exe);
        if (index != -1) return;
      }

      nsCOMPtr aApp;
      if (!GetLocalHandlerApp(appFilesystemCommand, aApp)) return;

      // Save in our main tracking arrays
      appList->AppendElement(aApp);
      trackList.AppendElement(lower);
    }