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

test/read-4bitIMA.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-4bitIMA.js ➔ describe(ꞌ4-bit IMA ADPCM 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
 * Wavefile
3
 * Copyright (c) 2017 Rafael da Silva Rocha.
4
 * 
5
 */
6
7 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...
8
9
describe("4-bit IMA ADPCM reading", function() {
10
11
    let fs = require("fs");
12
    let wavefile = require("../index.js");
13
    let path = "test/files/";
14
15
    let wBytes = fs.readFileSync(path + '4bit-imaadpcm-8kHz-noBext-mono.wav');
16
    let wav = new wavefile.WaveFile(wBytes);
17
18
    it("chunkId should be 'RIFF'",
19
            function() {
20
        assert.equal(wav.chunkId, "RIFF");
21
    });
22
    it("subChunk1Id should be 'fmt '",
23
            function() {
24
        assert.equal(wav.subChunk1Id, "fmt ");
25
    });
26
    it("format should be 'WAVE'",
27
            function() {
28
        assert.equal(wav.format, "WAVE");
29
    });
30
    it("subChunk1Size should be 20",
31
            function() {
32
        assert.equal(wav.subChunk1Size, 20);
33
    });
34
    it("audioFormat should be 17 (IMA ADPCM)",
35
            function() {
36
        assert.equal(wav.audioFormat, 17);
37
    });
38
    it("numChannels should be 1",
39
            function() {
40
        assert.equal(wav.numChannels, 1);
41
    });
42
    it("sampleRate should be 8000",
43
            function() {
44
        assert.equal(wav.sampleRate, 8000);
45
    });
46
    it("bitsPerSample should be 4",
47
            function() {
48
        assert.equal(wav.bitsPerSample, 4);
49
    });
50
    it("factChunkId should be 'fact'",
51
            function() {
52
        assert.equal(wav.factChunkId, 'fact');
53
    });
54
    it("factChunkSize should be 4",
55
            function() {
56
        assert.equal(wav.factChunkSize, 4);
57
    });
58
    it("subChunk2Id should be 'data'",
59
            function() {
60
        assert.equal(wav.subChunk2Id, 'data');
61
    });
62
    it("subChunk2Size should be > 0",
63
            function() {
64
        assert.ok(wav.subChunk2Size > 0);
65
    });
66
    it("samples.length should be > 0",
67
            function() {
68
        assert.ok(wav.samples_.length > 0);
69
    });
70
});
71