-
Notifications
You must be signed in to change notification settings - Fork 9
/
appraisal-data.js
126 lines (124 loc) · 3.56 KB
/
appraisal-data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
*
* @module readme-inspector/appraisal-data
*
* Represents a numerical score from 0 to 100 for a Github-style README.
* The intention is to measure complexity, which the authors of the
* readme-score-api believe to be "generally correlated with quality."
*
* AppraisalData does not measure whether one README is absolutely better
* than another, but it does indicated whether a README is high-quality,
* needs more work, or somewhere in-between.
*
* @typedef AppraisalData
* @type {object}
*
* @prop {Error|null} err=null - A Error object or `null`.
*
* @prop {number} score=0 - The sum of all values in the breakdown collection.
*
* @prop {string} url=null - The location of the README that was evaluated.
*
* @prop {object} breakdown - A collection of README file quality measures.
* @prop {number} breakdown.cumulativeCodeBlockLength=0 - Amount of code.
*
* * Value of each: 0.0009475244447271192
* * Maximum allowed total: 10
*
* @prop {number} breakdown.hasLists=0 - Total count of lists.
*
* * Value per list: 10
*
* @prop {number} breakdown.lowCodeBlockPenalty=0 - Penalty for lack of code blocks.
*
* * Metric: code-block count
* * Rule: if there are fewer than three code blocks, deduct 10 points.
*
* @prop {number} breakdown.numberOfCodeBlocks=0 - The total count of source code
* examples on the README.md document.
*
* * Value per code block: 5
* * Maximum allowed total: 40
*
* @prop {number} breakdown.numberOfGifs=0 - Number of GIF images.
*
* * Value per code block: 5
* * Maximum allowed total: 15
*
* @prop {number} breakdown.numberOfImages=0 - Number of images.
*
* * Value per code block: 5
* * Maximum allowed total: 15
*
* @prop {number} breakdown.numberOfNonCodeSections=0 - The total count of sections
* in the README that do _not_ contain source code.
*
* * Value per section: 5
* * Maximum allowed total: 30
*
* @example
* // Successfully appraise a high-quality README.
*
* const {ReadmeAppraisal} = require('readme-inspector')
* const readmeAppraisal = new ReadmeAppraisal()
* const appraisal = readmeAppraisal.for('commonality/readme-inspector')
*
* const WHITESPACE = 2
* console.log(JSON.stringify(appraisal, null, WHITESPACE))
* // =>
* {
* "breakdown": {
* "cumulativeCodeBlockLength": 10,
* "hasLists": 10,
* "lowCodeBlockPenalty": 0,
* "numberOfCodeBlocks": 40,
* "numberOfGifs": 0,
* "numberOfImages": 15,
* "numberOfNonCodeSections": 30
* },
* "error": null,
* "score": 100,
* "url": "commonality/readme-inspector"
* }
*
* @example
* // Return a `NullAppraisal` for a repository that doesn't
* // have a README.
*
* const readmeInspector = require('readme-inspector')
* const appraisal =
* await readmeInspector.getAppraisal('https://github.com/gregswindle/no-readme')
*
* const WHITESPACE = 2
* console.log(JSON.stringify(appraisal, null, WHITESPACE))
* // =>
* {
* "breakdown": {
* "cumulativeCodeBlockLength": 0,
* "hasLists": 0,
* "lowCodeBlockPenalty": 0,
* "numberOfCodeBlocks": 0,
* "numberOfGifs": 0,
* "numberOfImages": 0,
* "numberOfNonCodeSections": 0
* },
* "error": "Could not determine score for https://github.com/gregswindle/no-readme",
* "score": 0,
* "url": null
* }
*/
const appraisal = {
'breakdown': {
'cumulativeCodeBlockLength': 0,
'hasLists': 0,
'lowCodeBlockPenalty': 0,
'numberOfCodeBlocks': 0,
'numberOfGifs': 0,
'numberOfImages': 0,
'numberOfNonCodeSections': 0
},
'error': null,
'score': 0,
'url': null
}
module.exports = appraisal