Ejemplo n.º 1
0
 private bool IsInconsistentFormulaBug(BugKind b)
 {
     return
         (b == BugKind.ReferenceBug ||
          b == BugKind.ReferenceBugInverse ||
          b == BugKind.CalculationError);
 }
Ejemplo n.º 2
0
 private bool IsTrueRefBug(BugKind b)
 {
     return
         (b == BugKind.FormulaWhereConstantExpected ||
          b == BugKind.ConstantWhereFormulaExpected ||
          b == BugKind.ReferenceBug ||
          b == BugKind.ReferenceBugInverse ||
          b == BugKind.CalculationError);
 }
Ejemplo n.º 3
0
 public BugAnnotation(BugKind bugKind, string note)
 {
     BugKind = bugKind;
     Note    = note;
 }
Ejemplo n.º 4
0
 private bool IsSuspiciousCell(BugKind b)
 {
     return
         (b == BugKind.SuspiciousCell);
 }
Ejemplo n.º 5
0
 private bool IsWhitespaceBug(BugKind b)
 {
     return
         (b == BugKind.OperationOnWhitespace);
 }
Ejemplo n.º 6
0
 private bool IsMissingFormulaBug(BugKind b)
 {
     return
         (b == BugKind.FormulaWhereConstantExpected ||
          b == BugKind.ConstantWhereFormulaExpected);
 }
Ejemplo n.º 7
0
        private ExceLintGroundTruth(string dbpath, ExceLintGroundTruthRow[] rows)
        {
            Console.WriteLine("Indexing ExceLint bug database...");

            _dbpath = dbpath;

            foreach (var row in rows)
            {
                if (row.Address != "Address")
                {
                    AST.Address addr = Address(row.Address, row.Worksheet, row.Workbook);
                    _bugs.Add(addr, BugKind.ToKind(row.BugKind));
                    _notes.Add(addr, row.Notes);
                }
            }

            // index workbooks
            _has_annotations_for_workbook = new HashSet <string>(_bugs.Keys.Select(a => a.WorkbookName).Distinct());

            // find all bugclasses
            foreach (KeyValuePair <AST.Address, BugKind> kvp in _bugs)
            {
                // get address
                var addr = kvp.Key;

                // get duals, if there are any
                var dual_opt = DualsFor(addr);
                if (FSharpOption <BugClass> .get_IsSome(dual_opt))
                {
                    // dual bugclass
                    var duals = dual_opt.Value;

                    // store each dual address in a bugclass if it hasn't already been stored
                    foreach (AST.Address caddr in duals)
                    {
                        // if no bugclass is stored for address
                        if (!_bugclass_lookup.ContainsKey(caddr))
                        {
                            // add it
                            _bugclass_lookup.Add(caddr, duals);
                        }
                    }

                    // get all the addresses in dual and saved bugclasses
                    var classaddrs = duals.SelectMany(caddr => _bugclass_lookup[caddr]).Distinct().ToArray();

                    // get an arbitrary bugclass
                    var fstbugclass = _bugclass_lookup[classaddrs.First()];

                    // is every address in this class?  if not, add them
                    foreach (AST.Address caddr in classaddrs)
                    {
                        if (!fstbugclass.Contains(caddr))
                        {
                            fstbugclass.Add(caddr);
                        }
                    }

                    // ensure that every address refers to the very same bugclass object
                    foreach (AST.Address caddr in classaddrs)
                    {
                        _bugclass_lookup[caddr] = fstbugclass;
                    }

                    // now make sure that the dual lookup for addr points to fstbugclass
                    _dual_lookup.Add(addr, fstbugclass);
                }
            }

            // make sure that all of the bugs in the dual bugclasses have lookups for their own bugclasses
            foreach (var kvp in _dual_lookup)
            {
                var bugclass = kvp.Value;

                foreach (var addr in bugclass)
                {
                    if (!_bugclass_lookup.ContainsKey(addr))
                    {
                        _bugclass_lookup.Add(addr, bugclass);
                    }
                }
            }

            // make sure that every bug remaining (i.e., those without duals) is in a bugclass
            foreach (var kvp in _bugs)
            {
                var addr = kvp.Key;
                if (!_bugclass_lookup.ContainsKey(addr))
                {
                    var bc = new HashSet <AST.Address>();
                    bc.Add(addr);
                    _bugclass_lookup.Add(addr, bc);
                }
            }

            // now index bugclass -> bugclass dual lookup
            foreach (var kvp in _bugclass_lookup)
            {
                var addr     = kvp.Key;
                var bugclass = kvp.Value;

                // did we already save the dual for this bugclass?
                if (!_bugclass_dual_lookup.ContainsKey(bugclass))
                {
                    // grab the dual bugclass for this bugclass, if it has one
                    if (_dual_lookup.ContainsKey(addr))
                    {
                        var dual = _dual_lookup[addr];

                        // since the bugclass should be the same for all
                        // addresses in the bugclass, just lookup the bugclass
                        // by an arbitrary representative address
                        var fstdual       = dual.First();
                        var dual_bugclass = _bugclass_lookup[fstdual];

                        // now save it
                        _bugclass_dual_lookup.Add(bugclass, dual_bugclass);
                    }
                }
            }

            // sanity checks

            // every bug mentioned in notes has an entry in the lookup table
            foreach (var kvp in _bugclass_lookup)
            {
                var addr = kvp.Key;
                if (!_bugs.ContainsKey(addr))
                {
                    Console.WriteLine("WARNING: Address " + addr.A1FullyQualified() + " referenced in bug notes but not annotated.");
                }
            }

            // all duals are mutually exclusive
            foreach (var kvp in _bugclass_dual_lookup)
            {
                BugClass bc1 = kvp.Key;
                BugClass bc2 = kvp.Value;

                if (bc1.Intersect(bc2).Count() > 0)
                {
                    string bc1str = String.Join(",", bc1.Select(a => a.A1Local()));
                    string bc2str = String.Join(",", bc2.Select(a => a.A1Local()));
                    string wb     = bc1.First().A1Workbook();
                    string ws     = bc1.First().A1Worksheet();
                    Console.WriteLine(
                        "WARNING: bug class\n\t" +
                        bc1str +
                        "\n\tis not mutually exclusive with bug class\n\t" +
                        bc2str +
                        "\n\tin workbook " + wb + " on worksheet " + ws);
                }
            }

            Console.WriteLine("Done indexing ExceLint bug database.");
        }
Ejemplo n.º 8
0
 private bool IsTrueRefBugOrSuspicious(BugKind b)
 {
     return
         (IsTrueRefBug(b) ||
          b == BugKind.SuspiciousCell);
 }