routes/database.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 33
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
cc 0
c 4
b 0
f 1
nc 1
dl 0
loc 33
rs 10
wmc 5
mnd 2
bc 7
fnc 3
bpm 2.3333
cpm 1.6666
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A database.js ➔ getProjects 0 21 1
1
var mysql = require('mysql');
2
3
var connection = mysql.createPool({
4
    host: '76.14.31.246',
5
    user: 'api',
6
    password: 'webaccess1992',
7
    port: '3306',
8
    database: 'personal_website'
9
});
10
11
function getProjects(tableName, callback) {
12
13
    connection.getConnection(function(err, connection) {
14
        if(err) {
15
            console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
16
        }
17
        else {
18
            console.log(tableName);
19
            var query = 'SELECT * FROM ' + tableName;
20
            connection.query(query, null, function(error, result) {
21
                if(error) {
22
                    console.log(error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
23
                }
24
                else {
25
                    callback(error, result);
26
                }
27
            });
28
        }
29
        connection.release();
30
    });
31
}
32
33
exports.getProjects = getProjects;
34