npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

miniprogram-analyzer2

v0.0.8

Published

miniprogram analyzer based on plato

Downloads

7

Readme

miniprogram-analyzer

Intro

评估小程序代码质量

使用

项目启动

$ git clone https://github.com/miniprogram-analyzer/miniprogram-analyzer.git
$ cd miniprogram-analyzer
$ npm install

代码分析

使用帮助

$ node bin/index.js analyze -h # 查看使用帮助

示例

$ node bin/index.js analyze example/weiyou
报告输出至:plato-mini-program-zh-CN/report/weiyou

分析报告:

report/weiyou
├── plato       # 分析报告 HTML
└── report.json # 详细信息

API

inspect(mpDir, reportDir, options?):

return Promise<object>

mpDir

Type: string

miniprogram directory

reportDir

Type: string

report directory

options

Type: object

{
    platoOptions
}

代码质量衡量指标说明

Code Metrics

:point_right: 示例: report/weiyou/reports.json

| 指标 | 说明 | | ---------------- | -------------------------------------- | | pages | 页面列表 | | hasCloudFunction | 是否使用云开发 | | components | 使用到的组件 | | wxAPIs | 使用到的小程序 API | | CSSLOC | wxss 代码行数(经过 stylelint 格式化) | | plato | plato 相关 |

plato 生成页面指标说明

总 Summary

  1. Total Lines 总代码行数,表示文件中的代码总行数。
  2. Average Lines 平均代码行数
  3. Maintainability 代码可维护性指标,参考说明 Maintainability Index = MAX(0,(171 - 5.2 * log(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * log(Lines of Code))*100 /171) 可维护性指标为0-100之间的数字,数值越大表示越易于维护。 20-100:易于维护 10-19:较难维护 0-9:很难维护
  4. Average Maintainability 平均代码可维护性,依据各文件取平均得出
  5. Lines of code 各文件代码行数
  6. Estimated errors in implementation 潜在bug数估计,依据Halstead模型得出
  7. Lint errors jsLint错误数,不符合约定编程风格错误数

各文件衡量指标

  1. Difficulty 文件中去重操作数越难;重复操作符越多,越难。依据Halstead模型得出
  2. Complexity 圈复杂度,表示代码块中所有可能的路径数。圈复杂度越低越好。 降低圈复杂度的方法:减少分支数。圈复杂度说明
  3. Function weight 函数权重。有如下几种分类方式: By Complexity:按圈复杂度统计 BySLOC:按照SLOC/LSLOC(源代码行/逻辑代码行)统计。 SLOC:物理代码行,统计物理行数,包括注释、空行等。 LSLOC:逻辑代码行,统计语句数。