Documentation comment not found for arrow function expression
test6
169 t.is(deletedArray[0].hash, 'ca90917cccffe77b6c01bab4a3ebc77243d784e1874dda8f35e217a858ea05f2');
170 };
171
172 const test6 = () => {173 t.log('Compare initial commit with 3rd commit');
174 const diff = new Diff(commit3, commit0, { includeDirs: true });
175
Documentation comment not found for function declaration
writeFileAndCommit
11
12const sortPaths = require('sort-paths');
13
14function writeFileAndCommit(repo: Repository, filename: string, message: string): Promise<Commit> { 15 return fse.writeFile(join(repo.workdir(), filename), message)
16 .then(() => {
17 const index = repo.ensureMainIndex();
Documentation comment not found for function declaration
deleteFileAndCommit
23 });
24}
25
26function deleteFileAndCommit(repo: Repository, filename: string, message: string): Promise<Commit> { 27 return fse.unlink(join(repo.workdir(), filename))
28 .then(() => {
29 const index = repo.ensureMainIndex();
Documentation comment not found for arrow function expression
test0
53 // Commit 4: delete a file fooB.txt
54 const commit4: Commit = await deleteFileAndCommit(repo, 'fooB.txt', 'delete fooB.txt');
55
56 const test0 = () => { 57 t.log('Compare initial commit with itself');
58 const diff = new Diff(commit0, commit0, { includeDirs: true });
59
Documentation comment not found for arrow function expression
test1
70 t.is(deletedArray.length, 0, 'expected 0 elements');
71 };
72
73 const test1 = () => { 74 t.log('Compare initial commit with first commit');
75 const diff = new Diff(commit1, commit0, { includeDirs: true });
76
Documentation comment not found for arrow function expression
test2
89 t.is(deletedArray.length, 0, 'expected 0 elements');
90 };
91
92 const test2 = () => { 93 t.log('Compare second commit with first commit');
94 const diff = new Diff(commit2, commit1, { includeDirs: true });
95
Documentation comment not found for arrow function expression
test3
108 t.is(deletedArray.length, 0, 'expected 0 elements');
109 };
110
111 const test3 = () => {112 t.log('Compare second commit with itself');
113 const diff = new Diff(commit2, commit2, { includeDirs: true });
114
Documentation comment not found for arrow function expression
test4
127 t.is(deletedArray.length, 0, 'expected 0 elements');
128 };
129
130 const test4 = () => {131 t.log('Compare 3rd commit with 2nd commit');
132 const diff = new Diff(commit3, commit2, { includeDirs: true });
133
Documentation comment not found for arrow function expression
test5
148 t.is(deletedArray.length, 0, 'expected 0 elements');
149 };
150
151 const test5 = () => {152 t.log('Compare 4th commit with 3rd commit');
153 const diff = new Diff(commit4, commit3, { includeDirs: true });
154
Documentation comment not found for arrow function expression
test0
243
244 const commit2 = await repo.createCommit(index, 'commit2');
245
246 const test0 = () => {247 t.log('Compare initial commit with first commit');
248 const diff = new Diff(commit1, commit0, { includeDirs: true });
249
Documentation comment not found for arrow function expression
test1
280 t.is(deletedArray.length, 0, 'expected 0 elements');
281 };
282
283 const test1 = () => {284 t.log('Compare 2nd commit with first commit');
285 const diff = new Diff(commit2, commit1, { includeDirs: true });
286
Description
It is recommended to have documentation comments above, or right inside a function/class declaration. This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.
NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skipdoccoverage option under the analyzers.meta
property in your .deepsource.toml
file.
For example, the following configuration will silence this issue for class expressions and method definitions:
[analyzers.meta]
skip_doc_coverage = ["class-expression", "method-definition"]
Bad Practice
function sum(a, b) {
return a + b;
}
Recommended
/**
* Function to add two numbers
* @param a The first number to add
* @param b The second number to add
* @returns The sum of two numbers
*/
function sum(a, b) {
return a + b;
}