GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9e2664...6ddc55 )
by Stefano
02:30
created

program.action   A

Complexity

Conditions 1
Paths 5

Size

Total Lines 58

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 58
rs 9.639

1 Function

Rating   Name   Duplication   Size   Complexity  
C 0 50 9

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
var program = require('commander');
2
var shell = require('shelljs');
3
var chalk = require('chalk');
4
var co = require('co');
5
var prompt = require('co-prompt');
6
var fs = require('fs');
7
8
program
9
  .usage('[options] <enviroment ...>')
10
  .arguments('<enviroment>')
11
  .action(function(enviroment) {
12
13
    shell.echo('Compile Workspace ('+enviroment+')');
14
15
    shell.cd('applications/workspace/');
16
17
    fs.readFile('config.php.dist', 'utf8', function (err,data) {
18
19
      if (err) {
20
        process.stderr.write(chalk.red("Errore in lettura: "+err));
21
        process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
22
      }
23
24
      var result;
25
      if ( enviroment === 'dev' ){
26
        result = data.replace(/##TYPE##/g, 'sqlite');
27
        result = result.replace(/##HOST##/g, 'ROOT_PATH.\'/../database/workspace.sqlite\'');
28
        result = result.replace(/##DBNAME##/g, '');
29
        result = result.replace(/##PASSWORD##/g, '');
30
        result = result.replace(/##USERNAME##/g, '');
31
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::DEBUG');
32
      } else if ( enviroment === 'vagrant' ){
33
        result = data.replace(/##TYPE##/g, 'mysql');
34
        result = result.replace(/##HOST##/g, '\'localhost\'');
35
        result = result.replace(/##DBNAME##/g, 'workspace');
36
        result = result.replace(/##PASSWORD##/g, 'workspace');
37
        result = result.replace(/##USERNAME##/g, 'workspace');
38
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::DEBUG');
39
      } else {
40
        // STAGING / PROD
41
        result = data.replace(/##TYPE##/g, 'mysql');
42
        if (
43
          !process.env.npm_package_config_database_host ||
44
          !process.env.npm_package_config_database_host ||
45
          !process.env.npm_package_config_database_dbname ||
46
          !process.env.npm_package_config_database_password ||
47
          !process.env.npm_package_config_database_username
48
        ) {
49
          process.stderr.write(chalk.red("Errore manca la configurazione in .npmrc"));
50
          process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
51
        }
52
        result = result.replace(/##HOST##/g, '\''+process.env.npm_package_config_database_host+'\'');
53
        result = result.replace(/##DBNAME##/g, process.env.npm_package_config_database_dbname);
54
        result = result.replace(/##PASSWORD##/g, process.env.npm_package_config_database_password);
55
        result = result.replace(/##USERNAME##/g, process.env.npm_package_config_database_username);
56
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::INFO');
57
      }
58
59
60
      fs.writeFile('config.php', result, 'utf8', function (err) {
61
         if (err) {
62
           process.stderr.write(chalk.red("Errore in scrittura: "+err));
63
           process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
64
         }
65
      });
66
    });
67
68
  })
69
  .parse(process.argv);
70
71
72
if (!process.argv.slice(2).length) {
73
  program.outputHelp(make_red);
74
}
75
76
function make_red(txt) {
77
  return chalk.red(txt);
78
}
79