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.

Issues (890)

src/lib/orov.TranslationResourceManager.js (2 issues)

1
var fs = require('fs');
2
var logger=require('AppFramework.js').logger;
3
var TranslationResourceManager = function TranslationResourceManager(lang, httpRouter, resourceFilePath, options) {
4
  this.lang = lang;
5
  this.router = httpRouter;
6
  this.dirname = resourceFilePath;
7
  this.namespaceSeperator = options.namespaceSeperator || ':::';
8
  this.keySeperator = options.keySeperator || '::';
9
  this.addMissingTranslations = options.addMissingTranslations || false;
10
  this.updatesCache = {};
11
  this.updatesCache_dirty = false;
12
  if (this.addMissingTranslations) {
13
    this.monitorMissingData();
14
  }
15
  this.setRoutes();
16
};
17
TranslationResourceManager.prototype.monitorMissingData = function monitorMissingData() {
18
  var self = this;
19
  var writeDataToFileInterval = setInterval(function () {
20
      if (!self.updatesCache_dirty)
21
        return;
22
      var nskeys = Object.keys(self.updatesCache);
23
      nskeys.forEach(function (key) {
24
        var file = self.dirname + '/' + key + '.json';
25
        fs.exists(file, function (exists) {
26
          if (exists)
27
            return;
28
          fs.writeFileSync(file, '{}');
29
        });
30
        var _updates = self.updatesCache[key];
31
        fs.readFile(file, function (err, data) {
32
          if (err) {
33
            return logger.error(err);
34
          }
35
          var itemkeys = Object.keys(_updates);
36
          var json = JSON.parse(data);
37
          itemkeys.forEach(function (ikeys) {
38
            json[ikeys] = _updates[ikeys];
39
          });
40
          var newJSON = JSON.stringify(json, null, 2);
41
          fs.writeFileSync(file, newJSON);
42
        });
43
      });
44
      self.updatesCache = {};
45
      self.updatesCache_dirty = false;
46
    }, 5000);
47
};
48
TranslationResourceManager.prototype.setRoutes = function setRoutes() {
49
  var self = this;
50
  this.router.get('/locales/' + this.lang + '/:namespace', function (req, res) {
51
    var namespace = req.params.namespace;
52
    if (namespace.indexOf('.json') < 0) {
53
      namespace = namespace + '.json';
54
    }
55
    var file = self.dirname + '/' + namespace;
56
    fs.exists(file, function (exists) {
57
      if (exists)
58
        return;
59
      fs.writeFileSync(file, '{}');
60
    });
61
    fs.readFile(file, function (err, data) {
62
      if (err) {
63
        res.status(500);
64
        //          res.write(err)
65
        res.end;
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
66
        return logger.error(err);
67
      }
68
      res.writeHead(200, {
69
        'Content-Type': 'text/html',
70
        'Content-Length': data.length
71
      });
72
      res.write(data);
73
      res.end();
74
    });
75
  });
76
  this.router.post('/locales/add/' + this.lang + '/:namespace', function (req, res) {
77
    var ns = req.params.namespace;
78
    var newdata = req.body;
79
    var keys = Object.keys(newdata);
80
    if (self.updatesCache[ns] === undefined) {
81
      self.updatesCache[ns] = {};
82
    }
83
    for (i in keys) {
0 ignored issues
show
Creating global 'for' variable. Should be 'for (var i ...'.
Loading history...
84
      self.updatesCache[ns][keys[i]] = newdata[keys[i]].replace(req.params.namespace + self.namespaceSeperator, '');
85
    }
86
    res.status(200);
87
    res.end();
88
    self.updatesCache_dirty = true;
89
  });
90
};
91
module.exports = TranslationResourceManager;