代码统计工具介绍

代码统计工具介绍我研究了3个工具,队友们都说第3个比较好看。工具gitinspectorgitinspector安装部署准备npm工具下载安装:node-v14.16.0-linux-x64.tar.xzcd/roottarxfnode-v14.16.0-linux-x64.tar.xzcat

大家好,欢迎来到IT知识分享网。

我研究了3个工具,队友们都说第3个比较好看。

工具gitinspector

gitinspector安装部署

准备npm工具

下载安装:node-v14.16.0-linux-x64.tar.xz

cd /root
tar xf node-v14.16.0-linux-x64.tar.xz
cat >> /etc/profile << EOF 
export NODE_HOME=/root/node-v14.16.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
EOF
source /etc/profile 

检查:
代码统计工具介绍

安装gitinspector

npm i -g gitinspector

gitinspector的使用方式和效果图

检查仓库:

cd /data/repository/
git clone --bare http://账户:密码@gitlab.vonechain.com:9002/haianSCF/vchain-scf.git
gitinspector --format=html  -l -L -m -T -r -H /data/repository/vchain-scf.git  > /data/gitstats-report/vchain-scf.html

搭建nginx,将家目录配置为/data/gitstats-report/。此处我nginx端口是8800,ip是10.10.246.29
访问统计代码结果地址:http://10.10.246.29:8800/vchain-iot.html
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍

gitinspector的常用参数

// a2x -v gitinspector.txt; a2x -v -f manpage gitinspector.txt; a2x -v -f xhtml gitinspector.txt

GITINSPECTOR(1)
===============
:doctype: manpage
:man version: 0.4.2
:man source: gitinspector
:man manual: The gitinspector Manual


NAME
----
gitinspector - statistical analysis tool for git repositories


SYNOPSIS
--------
*gitinspector* [OPTION]... [REPOSITORY]


DESCRIPTION
-----------
Analyze and gather statistics about a git repository. The default analysis shows general statistics per author, which can be complemented with a timeline analysis that shows the workload and activity of each author. Under normal operation, gitinspector filters the results to only show statistics about a number of given extensions and by default only includes source files in the statistical analysis.

Several output formats are supported, including plain text, HTML, JSON and XML.


OPTIONS
-------
List information about the repository in REPOSITORY. If no repository is specified, the current directory is used. If multiple repositories are given, information will be fetched from the last repository specified.

Mandatory arguments to long options are mandatory for short options too. Boolean arguments can only be given to long options.

*-f, --file-types*=EXTENSIONS::
	A comma separated list of file extensions to include when computing statistics. The default extensions used are: java,c,cc,cpp,h,hh,hpp,py,glsl,rb,js,sql. Specifying a single '\*' asterisk character includes files with no extension. Specifying two consecutive '**' asterisk characters includes all files regardless of extension.

*-F, --format*=FORMAT::
	Defines in which format output should be generated; the default format is 'text' and the available formats are: html,htmlembedded,json,text,xml (see <<X1,*OUTPUT FORMATS*>>)

*--grading*[=BOOL]::
	Show statistics and information in a way that is formatted for grading of student projects; this is the same as supplying the options *-HlmrTw*

*-H, --hard*[=BOOL]::
	Track rows and look for duplicates harder; this can be quite slow with big repositories

*-l, --list-file-types*[=BOOL]::
	List all the file extensions available in the current branch of the repository

*-L, --localize-output*[=BOOL]::
	Localize the generated output to the selected system language if a translation is available

*-m,  --metrics*[=BOOL]::
	Include checks for certain metrics during the analysis of commits

*-r  --responsibilities*[=BOOL]::
	Show which files the different authors seem most responsible for

*--since*=DATE::
	Only show statistics for commits more recent than a specific date

*-T, --timeline*[=BOOL]::
	Show commit timeline, including author names

*--until*=DATE::
	Only show statistics for commits older than a specific date

*-w, --weeks*[=BOOL]::
	Show all statistical information in weeks instead of in months

*-x, --exclude*=PATTERN::
	An exclusion pattern describing the file paths, revisions, author names or author emails that should be excluded from the statistics; can be specified multiple times (see <<X2,*FILTERING*>>)

*-h, --help*::
	Display help and exit

*--version*::
	Output version information and exit


[[X1]]
OUTPUT FORMATS
--------------
There is support for multiple output formats in gitinspector. They can be selected using the *-F*/*--format* flags when running the main gitinspector script.

*text (plain text)*::
	Plain text with some very simple ANSI formatting, suitable for console output. This is the format chosen by default in gitinspector.

*html*::
	HTML with external links. The generated HTML page links to some external resources; such as the JavaScript library JQuery. It requires an active internet connection to properly function. This output format will most likely also link to additional external resources in the future.

*htmlembedded*::
	HTML with no external links. Similar to the HTML output format, but requires no active internet connection. As a consequence; the generated pages are bigger (as certain scripts have to be embedded into the generated output).

*json*::
	JSON suitable for machine consumption. If you want to parse the output generated by gitinspector in a script or application of your own; this format is suitable.

*xml*::
	XML suitable for machine consumption. If you want to parse the output generated by gitinspector in a script or application of your own; this format is suitable.


[[X2]]
FILTERING
---------
gitinspector offers several different ways of filtering out unwanted information from the generated statistics:

* *gitinspector -x myfile*, filter out and exclude statistics from all files (or paths) with the string "myfile"
* *gitinspector -x file:myfile*, filter out and exclude statistics from all files (or paths) with the string "myfile"
* *gitinspector -x author:John*, filter out and exclude statistics from all authors containing the string "John"
* *gitinspector -x email:@gmail.com*, filter out and exclude statistics from all authors with a gmail account
* *gitinspector -x revision:8755fb33*, filter out and exclude statistics from all revisions containing the hash "8755fb33"
* *gitinspector -x message:BUGFIX*, filter out and exclude statistics from all revisions containing "BUGFIX" in the commit message. 

The gitinspector command also lets you add multiple filtering rules by simply specifying the -x options several times or by separating each filtering rule with a comma;

* *gitinspector -x author:John -x email:@gmail.com*
* *gitinspector -x author:John,email:@gmail.com*

Sometimes, sub-string matching (as described above) is simply not enough. Therefore, gitinspector let's you specify regular expressions as filtering rules. This makes filtering much more flexible:

* *gitinspector -x "author:\^(?!(John Smith))"*, only show statistics from author "John Smith"
* *gitinspector -x "author:\^(?!([A-C]))"*, only show statistics from authors starting with the letters A/B/C
* *gitinspector -x "email:.com$"*, filter out statistics from all email addresses ending with ".com"


USING GIT TO CONFIGURE GITINSPECTOR
-----------------------------------
Options in gitinspector can be set using *git config*. Consequently, it is possible to configure gitinspector behavior globally (in all git repositories) or locally (in a specific git repository). It also means that settings will be permanently stored. All the long options that can be given to gitinspector can also be configured via git config (and take the same arguments).

To configure how gitinspector should behave in all git repositories, execute the following git command:

*git config --global inspector.option setting*

To configure how gitinspector should behave in a specific git repository, execute the following git command (with the current directory standing inside the repository in question):

*git config inspector.option setting*


AUTHOR
------
Originally written by Adam Waldenberg.


REPORTING BUGS
--------------
Report gitinspector bugs to gitinspector@ejwa.se

The gitinspector project page: <https://github.com/ejwa/gitinspector>

If you encounter problems, be sure to read the FAQ first: <https://github.com/ejwa/gitinspector/wiki/FAQ>

There is also an issue tracker at: <https://github.com/ejwa/gitinspector/issues>

COPYRIGHT
---------
Copyright (C) 2012-2015 Ejwa Software. All rights reserved. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.


SEE ALSO
--------
*git*(1)

工具gitstats

gitstats安装部署

yum install gitstats

gitstats的效果

git clone --bare http://账户:密码@gitlab.vonechain.com:9002/haianSCF/chain-sic.git
cd chain-sic
gitstats ./ /data/gitstats-report/chain-sic

代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍

工具gitstats的常用参数

查看帮助文档:
man gitstats

gitstats --help

Usage: gitstats [options] <gitpath..> <outputpath>

Options:
-c key=value     Override configuration value

Default config values:
{'linear_linestats': 1, 'style': 'gitstats.css', 'commit_end': 'HEAD', 'max_authors': 20, 'commit_begin': '', 'max_ext_length': 10, 'project_name': '', 'authors_top': 5, 'merge_authors': {}, 'max_domains': 10}

Please see the manual page for more details.

工具git_stats

git_stats:仓库代码统计工具之一,可以按git提交人、提交次数、修改文件数、代码行数、注释量在时间维度上进行统计,亦可按各文件类型进行简单的统计,非常方便.
虽然以代码行数来衡量项目或者程序员并不是一件靠谱的事,但是从统计角度看趋势对于技术管理人员还是很有帮助的!GitStats就是这样的工具,它能生成以下统计数据,并以图表形式进行对比
常规的统计:文件总数,行数,提交量,作者数。
活跃性:每天中每小时的、每周中每天的、每周中每小时的、每年中每月的、每年的提交量。
作者数:列举所有的作者(提交数,第一次提交日期,最近一次的提交日期),并按月和年来划分。
文件数:按日期划分,按扩展名名划分。
行数:按日期划分。

git_stats部署

安装ruby
# yum install ruby -y
添加ruby源
# gem sources -a https://gems.ruby-china.com/
安装ram管理工具
# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E37D2BAF1CF37B13E2069D6956105BD0E739499BDB

# curl -sSL https://get.rvm.io | bash -s stable
升级ruby版本
# source /etc/profile.d/rvm.sh
# rvm -v
# rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
# rvm list known
# rvm install 2.6
# ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]

# ls /usr/local/rvm/gems/
cache    ruby-2.5.8  ruby-2.5.8@global  ruby-2.6.6  ruby-2.6.6@global
若安装了多个ruby版本,需要设置一个默认的版本
# rvm use ruby-2.6.6 --default
通过gem安装git_stats
# gem sources -a http://mirrors.aliyun.com/rubygems/
# gem install git_stats
安装locate
# yum install mlocate -y
# updatedb 
添加git_stats中文支持,目录在config/locales/下
# cd /usr/local/rvm/gems/ruby-2.6.6/gems/git_stats-1.0.17/config/locales/
# cp zh_tw_default.yml zh_default.yml
修改最上边的zh_tw为zh_cn其他不变
# vim zh_default.yml     
zh_cn:
  date:
    abbr_day_names:
修改最上边的zh_tw为zh_cn其他不变
# vim zh.yml             
zh_cn:
  project_name: 项目名称

更新下索引
# updatedb            

git_stats的效果

为指定工程指定生成分析报告,我写了一个脚本

# cat git-stats.sh 
#!/bin/bash

List="vchain-scf-admin-front vchain-core vchain-siot vchain-sic vchain-scf vchain-bank vchain-framework vchain-credit-cloud-front vchain-scf-mini-front "

for i in $List ;
do
   cd /data/repository ; 
   echo ${i} ;
   git clone --bare http://账户:密码@gitlab.vonechain.com:9002/haianSCF/${i}.git ;
   cd ${i}.git ;
   git_stats generate -o /data/gitstats-report/${i} --language zh_cn ;
done

执行完脚本后,会生成如下文件:
代码统计工具介绍
访问路径:http://10.10.246.29:8800/工程名称/
比如:
http://10.10.246.29:8800/vchain-scf/
效果:
代码统计工具介绍

可以选择时间的好处就是,能根据迭代来统计。比如迭代1的时间是xxx1-xxx2,选择时间后可以只统计该迭代的代码情况。

代码统计工具介绍
代码统计工具介绍

代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍
代码统计工具介绍

git_stats的常用参数

# git_stats --help
/usr/local/rvm/gems/ruby-2.6.6/gems/activesupport-4.2.11.3/lib/active_support/core_ext/object/duplicable.rb:111: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
Commands:
  git_stats generate        # Generates the statistics of a repository
  git_stats help [COMMAND]  # Describe available commands or one specific command

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/31127.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信