Global Metrics

path: .metrics.halstead.N2
old: 53.0
new: 1075.0

path: .metrics.halstead.bugs
old: 0.19986995491515233
new: 3.7003774266399105

path: .metrics.halstead.level
old: 0.050314465408805034
new: 0.017700996677740864

path: .metrics.halstead.n2
old: 24.0
new: 333.0

path: .metrics.halstead.volume
old: 738.7474869206902
new: 20703.731991262484

path: .metrics.halstead.N1
old: 84.0
new: 1354.0

path: .metrics.halstead.n1
old: 18.0
new: 35.0

path: .metrics.halstead.length
old: 137.0
new: 2429.0

path: .metrics.halstead.effort
old: 14682.606302548718
new: 1169636.510767644

path: .metrics.halstead.purity_ratio
old: 1.3510784674691192
new: 1.2226669007113231

path: .metrics.halstead.time
old: 815.7003501415954
new: 64979.806153758

path: .metrics.halstead.vocabulary
old: 42.0
new: 368.0

path: .metrics.halstead.difficulty
old: 19.875
new: 56.493993993994

path: .metrics.halstead.estimated_program_length
old: 185.09775004326937
new: 2969.857901827804

path: .metrics.nargs.average
old: 1.25
new: 0.8636363636363636

path: .metrics.nargs.sum
old: 5.0
new: 19.0

path: .metrics.cyclomatic.sum
old: 7.0
new: 72.0

path: .metrics.cyclomatic.average
old: 1.4
new: 4.5

path: .metrics.nexits.average
old: 0.75
new: 1.181818181818182

path: .metrics.nexits.sum
old: 3.0
new: 26.0

path: .metrics.mi.mi_sei
old: 62.04033857380217
new: 20.729298852505224

path: .metrics.mi.mi_visual_studio
old: 43.56373106190105
new: 44.84745362918076

path: .metrics.mi.mi_original
old: 74.4939801158508
new: 76.68914570589911

path: .metrics.loc.ploc
old: 27.0
new: 423.0

path: .metrics.loc.blank
old: 8.0
new: 0.0

path: .metrics.loc.lloc
old: 11.0
new: 176.0

path: .metrics.loc.sloc
old: 42.0
new: 5.0

path: .metrics.loc.cloc
old: 7.0
new: 71.0

path: .metrics.cognitive.average
old: 0.5
new: 2.863636363636364

path: .metrics.cognitive.sum
old: 2.0
new: 63.0

path: .metrics.nom.closures
old: 0.0
new: 6.0

path: .metrics.nom.total
old: 4.0
new: 22.0

path: .metrics.nom.functions
old: 4.0
new: 16.0

Spaces Data

Minimal test - lines (184, 222)

path: .spaces[1].metrics.cyclomatic.sum
old: 2.0
new: 6.0

path: .spaces[1].metrics.cyclomatic.average
old: 2.0
new: 6.0

path: .spaces[1].metrics.loc.sloc
old: 11.0
new: 39.0

path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 2.0

path: .spaces[1].metrics.loc.ploc
old: 10.0
new: 27.0

path: .spaces[1].metrics.loc.blank
old: 1.0
new: 10.0

path: .spaces[1].metrics.loc.lloc
old: 5.0
new: 23.0

path: .spaces[1].metrics.mi.mi_visual_studio
old: 60.80589051705116
new: 44.92156551934133

path: .spaces[1].metrics.mi.mi_sei
old: 74.51143769369192
new: 52.91550153147877

path: .spaces[1].metrics.mi.mi_original
old: 103.97807278415748
new: 76.81587703807367

path: .spaces[1].metrics.halstead.estimated_program_length
old: 71.54887502163469
new: 197.27008269763

path: .spaces[1].metrics.halstead.difficulty
old: 11.333333333333334
new: 15.23076923076923

path: .spaces[1].metrics.halstead.volume
old: 206.43891887060175
new: 622.3752045246518

path: .spaces[1].metrics.halstead.time
old: 129.98006002963814
new: 526.6251730593208

path: .spaces[1].metrics.halstead.length
old: 47.0
new: 114.0

path: .spaces[1].metrics.halstead.bugs
old: 0.05874599141515827
new: 0.1493005789860304

path: .spaces[1].metrics.halstead.effort
old: 2339.6410805334867
new: 9479.253115067771

path: .spaces[1].metrics.halstead.vocabulary
old: 21.0
new: 44.0

path: .spaces[1].metrics.halstead.level
old: 0.08823529411764705
new: 0.06565656565656566

path: .spaces[1].metrics.halstead.N2
old: 17.0
new: 44.0

path: .spaces[1].metrics.halstead.n2
old: 9.0
new: 26.0

path: .spaces[1].metrics.halstead.N1
old: 30.0
new: 70.0

path: .spaces[1].metrics.halstead.n1
old: 12.0
new: 18.0

path: .spaces[1].metrics.halstead.purity_ratio
old: 1.5223164898220145
new: 1.7304393219090353

path: .spaces[1].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[1].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[1].metrics.cognitive.average
old: 1.0
new: 2.0

path: .spaces[1].metrics.cognitive.sum
old: 1.0
new: 2.0

path: .spaces[1].metrics.nexits.average
old: 0.0
new: 1.0

path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 1.0

Code

nsresult nsFilePicker::Show(int16_t* retval) {
  NS_ENSURE_ARG_POINTER(retval);

  *retval = returnCancel;

  int16_t userClicksOK = returnCancel;

  mFiles.Clear();
  nsCOMPtr theFile;

  // Note that GetLocalFolder shares a lot of code with GetLocalFiles.
  // Could combine the functions and just pass the mode in.
  switch (mMode) {
    case modeOpen:
      userClicksOK = GetLocalFiles(false, mFiles);
      break;

    case modeOpenMultiple:
      userClicksOK = GetLocalFiles(true, mFiles);
      break;

    case modeSave:
      userClicksOK = PutLocalFile(getter_AddRefs(theFile));
      break;

    case modeGetFolder:
      userClicksOK = GetLocalFolder(getter_AddRefs(theFile));
      break;

    default:
      NS_ERROR("Unknown file picker mode");
      break;
  }

  if (theFile) mFiles.AppendObject(theFile);

  *retval = userClicksOK;
  return NS_OK;
}

Minimal test - lines (93, 93)

path: .spaces[0].metrics.loc.blank
old: 2.0
new: 0.0

path: .spaces[0].metrics.loc.lloc
old: 3.0
new: 1.0

path: .spaces[0].metrics.loc.ploc
old: 7.0
new: 1.0

path: .spaces[0].metrics.loc.cloc
old: 1.0
new: 0.0

path: .spaces[0].metrics.loc.sloc
old: 10.0
new: 1.0

path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 2.0

path: .spaces[0].metrics.nargs.average
old: 1.0
new: 2.0

path: .spaces[0].metrics.nexits.average
old: 1.0
new: 0.0

path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[0].metrics.mi.mi_visual_studio
old: 62.41797731944472
new: 87.29022293215277

path: .spaces[0].metrics.mi.mi_original
old: 106.73474121625048
new: 149.26628121398124

path: .spaces[0].metrics.mi.mi_sei
old: 102.01526168899257
new: 139.7466915467399

path: .spaces[0].metrics.halstead.vocabulary
old: 17.0
new: 15.0

path: .spaces[0].metrics.halstead.N2
old: 14.0
new: 7.0

path: .spaces[0].metrics.halstead.length
old: 40.0
new: 16.0

path: .spaces[0].metrics.halstead.volume
old: 163.49851365001356
new: 62.5102495297363

path: .spaces[0].metrics.halstead.effort
old: 2098.230925175174
new: 328.1788100311156

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.33908807023343
new: 2.752443751081734

path: .spaces[0].metrics.halstead.bugs
old: 0.05463206306742344
new: 0.015859364080294203

path: .spaces[0].metrics.halstead.difficulty
old: 12.833333333333334
new: 5.25

path: .spaces[0].metrics.halstead.estimated_program_length
old: 53.5635228093372
new: 44.039100017307746

path: .spaces[0].metrics.halstead.level
old: 0.07792207792207792
new: 0.1904761904761905

path: .spaces[0].metrics.halstead.time
old: 116.56838473195413
new: 18.232156112839753

path: .spaces[0].metrics.halstead.N1
old: 26.0
new: 9.0

path: .spaces[0].metrics.halstead.n1
old: 11.0
new: 9.0

path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0

path: .spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 1.0

path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0

path: .spaces[0].metrics.cognitive.average
old: 1.0
new: 0.0

Code

void nsFilePicker::InitNative(nsIWidget* aParent, const nsAString& aTitle) { mTitle = aTitle; }

Minimal test - lines (224, 255)

path: .spaces[2].metrics.halstead.time
old: 77.03436650609419
new: 387.86212492828327

path: .spaces[2].metrics.halstead.volume
old: 151.26748332105768
new: 620.5793998852532

path: .spaces[2].metrics.halstead.purity_ratio
old: 1.9023735090854592
new: 1.821328113295428

path: .spaces[2].metrics.halstead.N1
old: 20.0
new: 68.0

path: .spaces[2].metrics.halstead.effort
old: 1386.6185971096954
new: 6981.518248709099

path: .spaces[2].metrics.halstead.bugs
old: 0.04144925786004325
new: 0.1217620628001556

path: .spaces[2].metrics.halstead.vocabulary
old: 20.0
new: 45.0

path: .spaces[2].metrics.halstead.estimated_program_length
old: 66.58307281799108
new: 205.81007680238335

path: .spaces[2].metrics.halstead.length
old: 35.0
new: 113.0

path: .spaces[2].metrics.halstead.N2
old: 15.0
new: 45.0

path: .spaces[2].metrics.halstead.n1
old: 11.0
new: 15.0

path: .spaces[2].metrics.halstead.n2
old: 9.0
new: 30.0

path: .spaces[2].metrics.halstead.level
old: 0.1090909090909091
new: 0.08888888888888889

path: .spaces[2].metrics.halstead.difficulty
old: 9.166666666666666
new: 11.25

path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 1.0

path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 1.0

path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 2.0

path: .spaces[2].metrics.cyclomatic.sum
old: 1.0
new: 2.0

path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 1.0

path: .spaces[2].metrics.loc.ploc
old: 6.0
new: 24.0

path: .spaces[2].metrics.loc.blank
old: 0.0
new: 7.0

path: .spaces[2].metrics.loc.lloc
old: 2.0
new: 6.0

path: .spaces[2].metrics.loc.sloc
old: 6.0
new: 32.0

path: .spaces[2].metrics.nargs.average
old: 1.0
new: 2.0

path: .spaces[2].metrics.nargs.sum
old: 1.0
new: 2.0

path: .spaces[2].metrics.mi.mi_original
old: 115.64443824983816
new: 80.95567987515084

path: .spaces[2].metrics.mi.mi_sei
old: 91.24062543682322
new: 54.819686970261934

path: .spaces[2].metrics.mi.mi_visual_studio
old: 67.62832646189366
new: 47.3425028509654

Code

static void UpdatePanelFileTypes(NSOpenPanel* aPanel, NSArray* aFilters) {
  // If we show all file types, also "expose" bundles' contents.
  [aPanel setTreatsFilePackagesAsDirectories:!aFilters];

  [aPanel setAllowedFileTypes:aFilters];
}

@implementation NSPopUpButtonObserver
- (void)setPopUpButton:(NSPopUpButton*)aPopUpButton {
  mPopUpButton = aPopUpButton;
}

- (void)setOpenPanel:(NSOpenPanel*)aOpenPanel {
  mOpenPanel = aOpenPanel;
}

- (void)setFilePicker:(nsFilePicker*)aFilePicker {
  mFilePicker = aFilePicker;
}

- (void)menuChangedItem:(NSNotification*)aSender {
  NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
  int32_t selectedItem = [mPopUpButton indexOfSelectedItem];
  if (selectedItem < 0) {
    return;
  }

  mFilePicker->SetFilterIndex(selectedItem);
  UpdatePanelFileTypes(mOpenPanel, mFilePicker->GetFilterList());

  NS_OBJC_END_TRY_BLOCK_RETURN();
}

Minimal test - lines (256, 348)

path: .spaces[3].metrics.cyclomatic.sum
old: 1.0
new: 13.0

path: .spaces[3].metrics.cyclomatic.average
old: 1.0
new: 13.0

path: .spaces[3].metrics.mi.mi_sei
old: 115.71718014704972
new: 32.17875864185019

path: .spaces[3].metrics.mi.mi_visual_studio
old: 77.54987902751634
new: 31.730539747707223

path: .spaces[3].metrics.mi.mi_original
old: 132.6102931370529
new: 54.25922296857935

path: .spaces[3].metrics.halstead.level
old: 0.23809523809523808
new: 0.051839464882943144

path: .spaces[3].metrics.halstead.n1
old: 7.0
new: 23.0

path: .spaces[3].metrics.halstead.N2
old: 6.0
new: 156.0

path: .spaces[3].metrics.halstead.volume
old: 50.18947501009619
new: 2331.7135383433742

path: .spaces[3].metrics.halstead.N1
old: 8.0
new: 184.0

path: .spaces[3].metrics.halstead.difficulty
old: 4.2
new: 19.29032258064516

path: .spaces[3].metrics.halstead.effort
old: 210.795795042404
new: 44979.50632030122

path: .spaces[3].metrics.halstead.n2
old: 5.0
new: 93.0

path: .spaces[3].metrics.halstead.time
old: 11.710877502355778
new: 2498.8614622389564

path: .spaces[3].metrics.halstead.estimated_program_length
old: 31.26112492884004
new: 712.1836944223581

path: .spaces[3].metrics.halstead.bugs
old: 0.01180646926336541
new: 0.4215882856054391

path: .spaces[3].metrics.halstead.vocabulary
old: 12.0
new: 116.0

path: .spaces[3].metrics.halstead.length
old: 14.0
new: 340.0

path: .spaces[3].metrics.halstead.purity_ratio
old: 2.2329374949171457
new: 2.0946579247716417

path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 12.0

path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 12.0

path: .spaces[3].metrics.loc.lloc
old: 1.0
new: 25.0

path: .spaces[3].metrics.loc.ploc
old: 3.0
new: 61.0

path: .spaces[3].metrics.loc.cloc
old: 0.0
new: 14.0

path: .spaces[3].metrics.loc.blank
old: 0.0
new: 18.0

path: .spaces[3].metrics.loc.sloc
old: 3.0
new: 93.0

path: .spaces[3].metrics.nargs.average
old: 1.0
new: 2.0

path: .spaces[3].metrics.nargs.sum
old: 1.0
new: 2.0

Code

@end

// Use OpenPanel to do a GetFile. Returns |returnOK| if the user presses OK in the dialog.
int16_t nsFilePicker::GetLocalFiles(bool inAllowMultiple, nsCOMArray& outFiles) {
  NS_OBJC_BEGIN_TRY_BLOCK_RETURN;

  int16_t retVal = (int16_t)returnCancel;
  NSOpenPanel* thePanel = [NSOpenPanel openPanel];

  SetShowHiddenFileState(thePanel);

  // Set the options for how the get file dialog will appear
  SetDialogTitle(mTitle, thePanel);
  [thePanel setAllowsMultipleSelection:inAllowMultiple];
  [thePanel setCanSelectHiddenExtension:YES];
  [thePanel setCanChooseDirectories:NO];
  [thePanel setCanChooseFiles:YES];
  [thePanel setResolvesAliases:YES];

  // Get filters
  // filters may be null, if we should allow all file types.
  NSArray* filters = GetFilterList();

  // set up default directory
  NSString* theDir = PanelDefaultDirectory();

  // if this is the "Choose application..." dialog, and no other start
  // dir has been set, then use the Applications folder.
  if (!theDir) {
    if (filters && [filters count] == 1 &&
        [(NSString*)[filters objectAtIndex:0] isEqualToString:@"app"])
      theDir = @"/Applications/";
    else
      theDir = @"";
  }

  if (theDir) {
    [thePanel setDirectoryURL:[NSURL fileURLWithPath:theDir isDirectory:YES]];
  }

  int result;
  nsCocoaUtils::PrepareForNativeAppModalDialog();
  if (mFilters.Length() > 1) {
    // [NSURL initWithString:] (below) throws an exception if URLString is nil.

    NSPopUpButtonObserver* observer = [[NSPopUpButtonObserver alloc] init];

    NSView* accessoryView = GetAccessoryView();
    [thePanel setAccessoryView:accessoryView];

    [observer setPopUpButton:[accessoryView viewWithTag:kSaveTypeControlTag]];
    [observer setOpenPanel:thePanel];
    [observer setFilePicker:this];

    [[NSNotificationCenter defaultCenter] addObserver:observer
                                             selector:@selector(menuChangedItem:)
                                                 name:NSMenuWillSendActionNotification
                                               object:nil];

    UpdatePanelFileTypes(thePanel, filters);
    result = [thePanel runModal];

    [[NSNotificationCenter defaultCenter] removeObserver:observer];
    [observer release];
  } else {
    // If we show all file types, also "expose" bundles' contents.
    if (!filters) {
      [thePanel setTreatsFilePackagesAsDirectories:YES];
    }
    [thePanel setAllowedFileTypes:filters];
    result = [thePanel runModal];
  }
  nsCocoaUtils::CleanUpAfterNativeAppModalDialog();

  if (result == NSFileHandlingPanelCancelButton) return retVal;

  // Converts data from a NSArray of NSURL to the returned format.
  // We should be careful to not call [thePanel URLs] more than once given that
  // it creates a new array each time.
  // We are using Fast Enumeration, thus the NSURL array is created once then
  // iterated.
  for (NSURL* url in [thePanel URLs]) {
    if (!url) {
      continue;
    }

    nsCOMPtr localFile;
    NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile));
    nsCOMPtr macLocalFile = do_QueryInterface(localFile);
    if (macLocalFile && NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)url))) {
      outFiles.AppendObject(localFile);
    }
  }