Passed
Branch master (ea9505)
by Rafael S.
01:23
created

test/read-16bit.js   A

Complexity

Total Complexity 14
Complexity/F 1

Size

Lines of Code 64
Function Count 14

Duplication

Duplicated Lines 64
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 64
loc 64
rs 10
c 1
b 0
f 0
wmc 14
mnd 0
bc 14
fnc 14
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A read-16bit.js ➔ describe(ꞌ16-bit readingꞌ) 62 62 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
/*!
2
 * Copyright (c) 2017 Rafael da Silva Rocha.
3
 * 
4
 */
5
6 View Code Duplication
let assert = require("assert");
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7
8
describe("16-bit reading", function() {
9
10
    let fs = require("fs");
11
    let wavefile = require("../index.js");
12
    let path = "test/files/";
13
    
14
    let wBytes = fs.readFileSync(path + "16-bit-8kHz-noBext-mono.wav");
15
    let wav = new wavefile.WaveFile(wBytes);
16
17
    it("chunkId should be 'RIFF'",
18
            function() {
19
        assert.equal(wav.chunkId, "RIFF");
20
    });
21
    it("subChunk1Id should be 'fmt '",
22
            function() {
23
        assert.equal(wav.subChunk1Id, "fmt ");
24
    });
25
    it("format should be 'WAVE'",
26
            function() {
27
        assert.equal(wav.format, "WAVE");
28
    });
29
    it("subChunk1Size should be 16",
30
            function() {
31
        assert.equal(wav.subChunk1Size, 16);
32
    });
33
    it("audioFormat should be 1 (PCM)",
34
            function() {
35
        assert.equal(wav.audioFormat, 1);
36
    });
37
    it("numChannels should be 1",
38
            function() {
39
        assert.equal(wav.numChannels, 1);
40
    });
41
    it("sampleRate should be 8000",
42
            function() {
43
        assert.equal(wav.sampleRate, 8000);
44
    });
45
    it("byteRate be 16000",
46
            function() {
47
        assert.equal(wav.byteRate, 16000);
48
    });
49
    it("blockAlign should be 2",
50
            function() {
51
        assert.equal(wav.blockAlign, 2);
52
    });
53
    it("bitsPerSample should be 16",
54
            function() {
55
        assert.equal(wav.bitsPerSample, 16);
56
    });
57
    it("subChunk2Id should be 'data'",
58
            function() {
59
        assert.equal(wav.subChunk2Id, 'data');
60
    });
61
    it("subChunk2Size should be > 0",
62
            function() {
63
        assert.ok(wav.subChunk2Size > 0);
64
    });
65
    it("samples.length should be > 0",
66
            function() {
67
        assert.ok(wav.samples_.length > 0);
68
    });
69
});
70