Find an assertion's likely 'source' by removing any references to twtl
in the stack trace
168712
function findAssertionSourceInTrace(trace) {

    var found = null;

    for (var i = 0, l = trace.length; i < l; ++i) {
      if (
        trace[i].file === stSkipStart.file &&
        trace[i].line >= stSkipStart.line &&
        trace[i].line <= stSkipEnd.line
      ) {
        break;
      }
      found = trace[i];
    }

    return found;

  }
491641
function getSourceMapsForCapture(capture, onFailure, onSuccess) {
  const urls = new Set();
  const sourcemaps = new Map();
  for (const id in capture.refs) {
    const ref = capture.refs[id];
    if ((ref.type === 'ScriptExecutable' ||
        ref.type === 'EvalExecutable' ||
        ref.type === 'ProgramExecutable' ||
        ref.type === 'FunctionExecutable') && ref.value.url) {
      urls.add(ref.value.url);
    }
  }
  urls.forEach((url) => {
    getSourceMapForUrl(url, onFailure, (sourcemap) => {
      sourcemaps.set(url, sourcemap);
      urls.delete(url);
      if (urls.size === 0) {
        onSuccess(sourcemaps);
      }
    });
  });
  if (urls.size === 0) {
    console.warn('No source information found in capture');
    onSuccess(sourcemaps);
  }
}
732807
function checkSourceFileWorker(node) {
            var links = getNodeLinks(node);
            if (!(links.flags & 1 /* TypeChecked */)) {
                // If skipLibCheck is enabled, skip type checking if file is a declaration file.
                // If skipDefaultLibCheck is enabled, skip type checking if file contains a
                // '/// <reference no-default-lib="true"/>' directive.
                if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
                    return;
                }
                // Grammar checking
                checkGrammarSourceFile(node);
                potentialThisCollisions.length = 0;
                deferredNodes = [];
                deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined;
                ts.forEach(node.statements, checkSourceElement);
                checkDeferredNodes();
                if (ts.isExternalModule(node)) {
                    registerForUnusedIdentifiersCheck(node);
                }
                if (!node.isDeclarationFile) {
                    checkUnusedIdentifiers();
                }
                deferredNodes = undefined;
                deferredUnusedIdentifierNodes = undefined;
                if (ts.isExternalOrCommonJsModule(node)) {
                    checkExternalModuleExports(node);
                }
                if (potentialThisCollisions.length) {
                    ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
                    potentialThisCollisions.length = 0;
                }
                links.flags |= 1 /* TypeChecked */;
            }
        }
1091134
def check(args, source_code, filename=None, options=None):
    """"""
    if args is None:
        return []
    if options is not None:
        args += options
    if any(['pyflakes' in arg for arg in args]):
        #  Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)
        #  Note: this code is not used right now as it is faster to invoke 
        #  pyflakes in current Python interpreter (see `check_with_pyflakes` 
        #  function above) than calling it through a subprocess
        source_code += '\n'
    if filename is None:
        # Creating a temporary file because file does not exist yet 
        # or is not up-to-date
        tempfd = tempfile.NamedTemporaryFile(suffix=".py", delete=False)
        tempfd.write(source_code)
        tempfd.close()
        args.append(tempfd.name)
    else:
        args.append(filename)
    cmd = args[0]
    cmdargs = args[1:]
    proc = programs.run_program(cmd, cmdargs)
    output = proc.communicate()[0].strip().decode().splitlines()
    if filename is None:
        os.unlink(tempfd.name)
    results = []
    coding = encoding.get_coding(source_code)
    lines = source_code.splitlines()
    for line in output:
        lineno = int(re.search(r'(\:[\d]+\:)', line).group()[1:-1])
        try:
            text = to_text_string(lines[lineno-1], coding)
        except TypeError:
            text = to_text_string(lines[lineno-1])
        except UnicodeDecodeError:
            # Needed to handle UnicodeDecodeError and force the use
            # of chardet to detect enconding. See issue 6970
            coding = encoding.get_coding(source_code, force_chardet=True)
            text = to_text_string(lines[lineno-1], coding)
        if 'analysis:ignore' not in text:
            message = line[line.find(': ')+2:]
            results.append((message, lineno))
    return results
1341656
def clean_traceback(tb):
    ''''''
    prefix = __file__[:__file__.find("feat/common/error.py")]
    regex = re.compile("(\s*File\s*\")(%s)([a-zA-Z-_\. \\/]*)(\".*)"
                       % prefix.replace("\\", "\\\\"))

    def cleanup(line):
        m = regex.match(line)
        if m:
            return m.group(1) + ".../" + m.group(3) + m.group(4)
        else:
            return line

    return '\n'.join(map(cleanup, tb.split('\n')))
40256
def _excepthook(self, etype, evalue, trace):
        
        if etype == ArgumentParserError:
            self.exit(code=CRITICAL,
                      message='error: {0}'.format(evalue),
                      extdata=self.parser.format_usage())
        else:
            self.exit(code=UNKNOWN,
                      message='Uncaught exception: {0} - {1}'
                              .format(etype.__name__, evalue),
                      extdata=''.join(traceback.format_tb(trace)))
922970
function isAliasOfMethod(version, method, suspect) {
    return method === suspect || _.includes(_.get(getMethodData(version), [method, 'aliases']), suspect)
}
250726
function() {
            var assert = this;

            // Backwards compatibility fix.
            // Allows the direct use of global exported assertions and QUnit.assert.*
            // Although, it's use is not recommended as it can leak assertions
            // to other tests from async tests, because we only get a reference to the current test,
            // not exactly the test where assertion were intended to be called.
            if ( !QUnit.config.current ) {
                throw new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) );
            }
            if ( !( assert instanceof Assert ) ) {
                assert = QUnit.config.current.assert;
            }
            return assert.test.push.apply( assert.test, arguments );
        }
143556
function symbolicateChromeTrace(traceFile, context) {
  const contentJson = JSON.parse(fs.readFileSync(traceFile, 'utf8'));
  if (contentJson.stackFrames == null) {
    console.error('Unable to locate `stackFrames` section in trace.');
    process.exit(1);
  }
  console.log(
    'Processing ' + Object.keys(contentJson.stackFrames).length + ' frames',
  );
  Object.values(contentJson.stackFrames).forEach(function(entry) {
    let line;
    let column;

    // Function entrypoint line/column; used for symbolicating function name
    // with legacy source maps (or when --no-function-names is set).
    let funcLine;
    let funcColumn;

    if (entry.funcVirtAddr != null && entry.offset != null) {
      // Without debug information.
      const funcVirtAddr = parseInt(entry.funcVirtAddr, 10);
      const offsetInFunction = parseInt(entry.offset, 10);
      // Main bundle always use hard-coded line value 1.
      // TODO: support multiple bundle/module.
      line = 1;
      column = funcVirtAddr + offsetInFunction;
      funcLine = 1;
      funcColumn = funcVirtAddr;
    } else if (entry.line != null && entry.column != null) {
      // For hbc bundle with debug info, name field may already have source
      // information for the bundle; we still can use babel/metro/prepack
      // source map to symbolicate the bundle frame addresses further to its
      // original source code.
      line = entry.line;
      column = entry.column;

      funcLine = entry.funcLine;
      funcColumn = entry.funcColumn;
    } else {
      // Native frames.
      return;
    }

    // Symbolicate original file/line/column.
    const addressOriginal = getOriginalPositionDetailsFor(
      line,
      column,
      UNKNOWN_MODULE_IDS,
      context,
    );

    let frameName;
    if (addressOriginal.functionName) {
      frameName = addressOriginal.functionName;
    } else {
      frameName = entry.name;
      // Symbolicate function name.
      if (funcLine != null && funcColumn != null) {
        const funcOriginal = getOriginalPositionFor(
          funcLine,
          funcColumn,
          UNKNOWN_MODULE_IDS,
          context,
        );
        if (funcOriginal.name != null) {
          frameName = funcOriginal.name;
        }
      } else {
        // No function line/column info.
        console.warn(
          'Warning: no function prolog line/column info; name may be wrong',
        );
      }
    }

    // Output format is: funcName(file:line:column)
    const sourceLocation = `(${addressOriginal.source}:${
      addressOriginal.line
    }:${addressOriginal.column})`;
    entry.name = frameName + sourceLocation;
  });
  console.log('Writing to ' + traceFile);
  fs.writeFileSync(traceFile, JSON.stringify(contentJson));
}
477333
def _sanity_check_output_source_follower_blocks(ir_blocks):
    """"""
    seen_output_source = False
    for block in ir_blocks:
        if isinstance(block, OutputSource):
            seen_output_source = True
        elif seen_output_source:
            if isinstance(block, (Backtrack, Traverse, Recurse)):
                raise AssertionError(u'Found Backtrack / Traverse / Recurse '
                                     u'after OutputSource block: '
                                     u'{}'.format(ir_blocks))
68660
def source(self):
        """"""
        full_src = self._source[self._slice]

        def is_empty_or_comment(line):
            return line.strip() == '' or line.strip().startswith('#')

        filtered_src = dropwhile(is_empty_or_comment, reversed(full_src))
        return ''.join(reversed(list(filtered_src)))
1153225
private void checkNameDeprecation(NodeTraversal t, Node n) {
    if (!n.isName()) {
      return;
    }

    if (!shouldEmitDeprecationWarning(t, n)) {
      return;
    }

    Var var = t.getScope().getVar(n.getString());
    JSDocInfo docInfo = var == null ? null : var.getJSDocInfo();

    if (docInfo != null && docInfo.isDeprecated()) {
      if (docInfo.getDeprecationReason() != null) {
        compiler.report(
            JSError.make(n, DEPRECATED_NAME_REASON, n.getString(), docInfo.getDeprecationReason()));
      } else {
        compiler.report(JSError.make(n, DEPRECATED_NAME, n.getString()));
      }
    }
  }
84349
def _get_source(self):
        
        logger.debug('Getting module source for webhook2lambda2sqs.lambda_func')
        orig = getsourcelines(lambda_func)
        src = ''
        in_docstr = False
        have_docstr = False
        for line in orig[0]:
            if line.strip() == '"""' and not in_docstr and not have_docstr:
                in_docstr = True
                continue
            if line.strip() == '"""' and in_docstr:
                in_docstr = False
                have_docstr = True
                continue
            if not in_docstr:
                src += line
        return src
431090
def wf_source_id?(source)
      if source.is_a?(String) && source.match(/^[\w\.\-]+$/) &&
         source.size < 1024
        return true
      end

      raise Wavefront::Exception::InvalidSourceId
    end
54623
def _source_info():
    
    ofi = inspect.getouterframes(inspect.currentframe())[2]
    try:
        calling_class = ofi[0].f_locals['self'].__class__
    except KeyError:
        calling_class = None
    # Tuple of file,line,calling_class,function_name
    return ofi[1], ofi[2], calling_class, ofi[3]
902889
def get_source_file_provenance(self, filename):
        """"""
        module_name = resolve.infer_module_name(filename, self.path)
        return resolve.Direct(filename, module_name)
1283231
def _extract_cause(cls, exc_val):
        """"""
        # See: https://www.python.org/dev/peps/pep-3134/ for why/what
        # these are...
        #
        # '__cause__' attribute for explicitly chained exceptions
        # '__context__' attribute for implicitly chained exceptions
        # '__traceback__' attribute for the traceback
        #
        # See: https://www.python.org/dev/peps/pep-0415/ for why/what
        # the '__suppress_context__' is/means/implies...
        nested_exc_vals = []
        seen = [exc_val]
        while True:
            suppress_context = getattr(
                exc_val, '__suppress_context__', False)
            if suppress_context:
                attr_lookups = ['__cause__']
            else:
                attr_lookups = ['__cause__', '__context__']
            nested_exc_val = None
            for attr_name in attr_lookups:
                attr_val = getattr(exc_val, attr_name, None)
                if attr_val is None:
                    continue
                nested_exc_val = attr_val
            if nested_exc_val is None or nested_exc_val in seen:
                break
            seen.append(nested_exc_val)
            nested_exc_vals.append(nested_exc_val)
            exc_val = nested_exc_val
        last_cause = None
        for exc_val in reversed(nested_exc_vals):
            f = cls.from_exception(exc_val, cause=last_cause,
                                   find_cause=False)
            last_cause = f
        return last_cause