用于监视git存储库中的代码债务的仪表板。

git-code-debt的Python项目详细描述


Build StatusCoverage Status

Git代码债务

用于监视git存储库中的代码债务的仪表板。

安装

pip install git-code-debt

用法

基本/tl;dr用法

制作generate_config.yaml
# required: repository to clone (can be anything `git clone` understands) even# a repository already on diskrepo:git@github.com:asottile/git-code-debt# required: database generation pathdatabase:database.db# optional: default Falseskip_default_metrics:false# optional: default []metric_package_names:[]# optional: default ^$ (python regex) to exclude paths such as '^vendor/'exclude:^$

调用cli
# Generate code metric data (substitute your own repo path)
$ git-code-debt-generate
# Start the server
$ git-code-debt-server database.db
< H3>更新现有数据库中的数据< EH3>

向数据库添加数据就像再次运行generate一样简单。 git-code-debt将从生成数据的git历史记录中提取 以前。

$ git-code-debt-generate

创建自己的指标

  1. 创建一个python项目,添加git-code-debt作为依赖项。
  2. 创建一个包,您可以在其中编写度量值
  3. 将包添加到metric_package_names中的generate_config.yaml

编写自定义度量的最简单方法是扩展 git_code_debt.metrics.base.SimpleLineCounterBase

下面是基类的外观

classSimpleLineCounterBase(DiffParserBase):# ...defshould_include_file(self,file_diff_stat):"""Implement me to return whether a filename should be included.        By default, this returns True.        :param FileDiffStat file_diff_stat:        """returnTruedefline_matches_metric(self,line,file_diff_stat):"""Implement me to return whether a line matches the metric.        :param bytes line: Line in the file        :param FileDiffStat file_diff_stat:        """raiseNotImplementedError

下面是一个度量示例

fromgit_code_debt.metrics.baseimportSimpleLineCounterBaseclassPython__init__LineCount(SimpleLineCounterBase):"""Counts the number of lines in __init__.py"""defshould_include_file(self,file_diff_stat):returnfile_diff_stat.filename==b'__init__.py'defline_matches_metric(self,line,file_diff_stat):# All lines in __init__.py matchreturnTrue

更复杂的度量可以扩展DiffParserBase

classDiffParserBase(object):# Specify __metric__ = False to not be included (useful for base classes)__metric__=Falsedefget_metrics_from_stat(self,commit,file_diff_stats):"""Implement me to yield Metric objects from the input list of        FileStat objects.        Args:            commit - Commit object            file_diff_stats - list of FileDiffStat objects        Returns:           generator of Metric objects        """raiseNotImplementedErrordefget_metrics_info(self):"""Implement me to yield `MetricInfo` objects."""raiseNotImplementedError

一些屏幕截图

指数

Example screen index

图表

Example screen graph

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java试图用Mockito模拟IntConsumer失败   java从ArrayList获取一个元素   是否可以调用。。xyz\jdk1。6\bin\java。从jdk1上运行的java程序执行。5\java。exe?   基于连通距离的Kmeans plus聚类算法在java中的应用   java源代码管理是否使Javadoc的@author和@since冗余?   java静态对象引用和非静态对象引用   java如何创建需要动态参数的对象   java试图将字符串添加到一个字符串列表中,但最终将字符串添加到两个字符串列表中。   javacom。凭直觉。ipp。例外Quickbooks中的异常   安全性是对JAR进行模糊处理,足以防止普通最终用户而不是专家黑客理解JAVA代码吗?   scala S3 java API未正确列出文件夹。   java会话超时后重定向到前一个用户上次访问的页面   java Android到excel。jExecl制作0b文件   从jtextfield java GUI向mysql表中插入值   java JMockit和Fest UI测试   单击swing中的add按钮时,java jtextfield从B3001开始递增1