Return the global line rate of the coverage report. If the
        `filename` file is given, return the line rate of the file.
969275
def line_rate(self, filename=None):
        
        if filename is None:
            el = self.xml
        else:
            el = self._get_class_element_by_filename(filename)

        return float(el.attrib['line-rate'])
292149
def check_yard_coverage(stat_lines)
      if config['min_coverage_percentage']
        match = stat_lines.last.match(/^\s*([\d.]+)%\s+documented\s*$/)
        unless match
          return :warn
        end

        yard_coverage = match.captures[0].to_f
        if yard_coverage >= config['min_coverage_percentage'].to_f
          return :pass
        end

        yard_coverage
      end
    end
1180475
def individual_report(coverage_path, current_project_path)
      if File.exist? coverage_path
        committed_files = git.modified_files + git.added_files

        unless current_project_path.nil?
          committed_files = committed_files.map do |s|
            current_project_path + '/' + s
          end
        end

        covered_files = JSON.parse(File.read(coverage_path), symbolize_names: true)[:files]
                            .select { |f| committed_files.include?(f[:filename]) }

        unless current_project_path.nil?
          covered_files.each { |f| f[:filename].sub!(%r{^#{current_project_path}/?}, '') }
        end

        return if covered_files.nil? || covered_files.empty?
        markdown individual_coverage_message(covered_files)
      else
        fail('Code coverage data not found')
      end
    end
303445
def get_global_count(self):
        
        
        # Check current number of json files in results directory and dump current json in new file
        path_to_json = self.results_folder_name + '/'
        json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
        Wrapper.global_count = len(json_files) + 1
        return Wrapper.global_count
1141092
def save_report(self, file_path):
        """"""
        try:
            report = self.create_report()
        except coverage.CoverageException as e:
            log.error('Failure to gather coverage:', exc_info=e)
        else:
            with open(file_path, 'w') as report_file:
                report_file.write(report)
195317
def generate_coverage_report(coverage_xml, compare_branch,
                             html_report=None, css_file=None,
                             ignore_staged=False, ignore_unstaged=False,
                             exclude=None, src_roots=None):
    
    diff = GitDiffReporter(
        compare_branch, git_diff=GitDiffTool(), ignore_staged=ignore_staged,
        ignore_unstaged=ignore_unstaged, exclude=exclude)

    xml_roots = [cElementTree.parse(xml_root) for xml_root in coverage_xml]
    coverage = XmlCoverageReporter(xml_roots, src_roots)

    # Build a report generator
    if html_report is not None:
        css_url = css_file
        if css_url is not None:
            css_url = os.path.relpath(css_file, os.path.dirname(html_report))
        reporter = HtmlReportGenerator(coverage, diff, css_url=css_url)
        with open(html_report, "wb") as output_file:
            reporter.generate_report(output_file)
        if css_file is not None:
            with open(css_file, "wb") as output_file:
                reporter.generate_css(output_file)

    reporter = StringReportGenerator(coverage, diff)
    output_file = sys.stdout if six.PY2 else sys.stdout.buffer

    # Generate the report
    reporter.generate_report(output_file)
    return reporter.total_percent_covered()
583964
def get_global_rate_limit(self):
        
        r = urllib.request.urlopen('https://archive.org/metadata/iamine-rate-limiter')
        j = json.loads(r.read().decode('utf-8'))
        return int(j.get('metadata', {}).get('rate_per_second', 300))
1372932
def total_percent_covered(self):
        
        total_lines = self.total_num_lines()

        if total_lines > 0:
            num_covered = total_lines - self.total_num_violations()
            return int(float(num_covered) / total_lines * 100)

        else:
            return 100
97629
def _get_report(self, with_line_nums=True):
		
		templ = '{} ← {}' if with_line_nums else '{}'

		return '\n'.join([
			templ.format(error.string, ','.join(map(str, sorted(set(lines)))))
			for error, lines in self.errors.items()])
735429
def total_coverage
      unless @project.nil?
        @total_coverage ||= begin
          total_project_lines = 0
          total_project_lines_tested = 0
          @project.coverage_files.each do |coverage_file|
            total_project_lines_tested += coverage_file.num_lines_tested
            total_project_lines += coverage_file.num_lines_testable
          end
          @total_coverage = (total_project_lines_tested / total_project_lines.to_f) * 100.0
        end
      end
    end
1270743
def benchmark_file(
        filename, compiler, include_dirs, (progress_from, progress_to),
        iter_count, extra_flags = ''):
    """"""
    time_sum = 0
    mem_sum = 0
    for nth_run in xrange(0, iter_count):
        (time_spent, mem_used) = benchmark_command(
            '{0} -std=c++11 {1} -c {2} {3}'.format(
                compiler,
                ' '.join('-I{0}'.format(i) for i in include_dirs),
                filename,
                extra_flags
            ),
            (
                progress_to * nth_run + progress_from * (iter_count - nth_run)
            ) / iter_count
        )
        os.remove(os.path.splitext(os.path.basename(filename))[0] + '.o')
        time_sum = time_sum + time_spent
        mem_sum = mem_sum + mem_used

    return {
        "time": time_sum / iter_count,
        "memory": mem_sum / (iter_count * 1024)
    }
941093
def total_statements(self, filename=None):
        
        if filename is not None:
            statements = self._get_lines_by_filename(filename)
            return len(statements)

        total = 0
        for filename in self.files():
            statements = self._get_lines_by_filename(filename)
            total += len(statements)

        return total
481583
def branch_rate(self, filename=None):
        
        if filename is None:
            el = self.xml
        else:
            el = self._get_class_element_by_filename(filename)

        return float(el.attrib['branch-rate'])
983929
def get_global_name_value(self):
        
        if self._has_global_stats:
            name, value = self.get_global()
            if not isinstance(name, list):
                name = [name]
            if not isinstance(value, list):
                value = [value]
            return list(zip(name, value))
        else:
            return self.get_name_value()
529720
def check_coverage():
    """"""
    with lcd(settings.LOCAL_COVERAGE_PATH):
        total_line = local('grep -n Total index.html', capture=True)
        match = re.search(r'^(\d+):', total_line)
        total_line_number = int(match.groups()[0])
        percentage_line_number = total_line_number + 5
        percentage_line = local(
            'awk NR=={0} index.html'.format(percentage_line_number),
            capture=True)
        match = re.search(r'(\d.+)%', percentage_line)
        try:
            percentage = float(match.groups()[0])
        except ValueError:
            # If there's no dotting try another search
            match = re.search(r'(\d+)%', percentage_line)
            percentage = float(match.groups()[0])
    if percentage < 100:
        abort(red('Coverage is {0}%'.format(percentage)))
    print(green('Coverage is {0}%'.format(percentage)))
1116291
def atexit(self):
        
        funcname = self.fn.__name__
        filename = self.fn.__code__.co_filename
        lineno = self.fn.__code__.co_firstlineno
        print("")
        print("*** COVERAGE RESULTS ***")
        print("%s (%s:%s)" % (funcname, filename, lineno))
        print("function called %d times" % self.ncalls)
        print("")
        fs = FuncSource(self.fn)
        for (filename, lineno), count in self.tracer.counts.items():
            if filename != fs.filename:
                continue
            fs.mark(lineno, count)
        print(fs)
        never_executed = fs.count_never_executed()
        if never_executed:
            print("%d lines were not executed." % never_executed)
80399
def line_counts_as_uncovered(line: str,
                             is_from_cover_annotation_file: bool) -> bool:
    

    # Ignore this line?
    if is_from_cover_annotation_file:
        # Already covered, or the tool deemed it not relevant for coverage.
        if not line.startswith('! '):
            return False

        content = line[2:]
    else:
        content = line

    # Ignore surrounding whitespace.
    content = content.strip()

    # Ignore end-of-line comments.
    # TODO: avoid # in strings, etc.
    if '#' in content:
        content = content[:content.index('#')].strip()

    # Ignored line pattern?
    if any(re.search(pat, content) for pat in IGNORED_LINE_PATTERNS):
        return False

    return (is_from_cover_annotation_file or
            line_content_counts_as_uncovered_manual(content))