codenautas/qa-control-server

View on GitHub

Showing 27 of 27 total issues

File qac-services.js has 976 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

var qacServices={};

var app = require('express')();
Severity: Major
Found in lib/qac-services.js - About 2 days to fix

    Function doRepoUpdate has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    qacServices.doRepoUpdate = function doRepoUpdate(info, repo_url, feedback, bitacora) {
        var clonePath = Path.normalize(info.project.path+'/source');
        var resultsPath = Path.normalize(info.project.path+'/result');
        var cucardasFile = Path.normalize(clonePath+'/cucardas.log');
        var qaControlWarnings;
    Severity: Major
    Found in lib/qac-services.js - About 4 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              thisModule.getAdminPage(req).then(function(content){
                  qacServices.noCacheHeaders(res, 'html');
                  content = html.html([qcsCommon.simpleHead(null, thisModule), content]);
                  res.end(content.toHtmlDoc({pretty:true, title:'admin qa-control'}));
              }).catch(function(err) {
      Severity: Major
      Found in lib/qac-services.js and 1 other location - About 2 hrs to fix
      lib/qac-services.js on lines 902..911

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 94.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  thisModule.getOrganizationPage(req, req.params.organization).then(function(content){
                      qacServices.noCacheHeaders(res, 'html');
                      content = html.html([qcsCommon.simpleHead(null, qacServices), content]);
                      res.end(content.toHtmlDoc({pretty:true, title:req.params.organization+' qa-control'}));
                  }).catch(function(err) {
      Severity: Major
      Found in lib/qac-services.js and 1 other location - About 2 hrs to fix
      lib/qac-services.js on lines 1052..1061

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 94.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function getInfo has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      qacServices.getInfo = function getInfo(organization, project){
          var info={};
          return Promise.resolve().then(function() {
              if(!organization) {
                  throw new Error('missing organization');
      Severity: Major
      Found in lib/qac-services.js - About 2 hrs to fix

        Function getProjectLogs has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        qacServices.getProjectLogs = function getProjectLogs(projectPath) {
            var r=[];
            return fs.readJSON(Path.normalize(projectPath+'/result/qa-control-result.json'), 'utf8').catch(function(err) {
                if(err.code !== 'ENOENT') { throw err; }
                return [];
        Severity: Minor
        Found in lib/qac-services.js - About 1 hr to fix

          Function createProject has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          qacServices.createProject = function createProject(organization, project) {
              var info;
              var projPath;
              var projects;
              return Promise.resolve().then(function() {
          Severity: Minor
          Found in lib/qac-services.js - About 1 hr to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                            if(qacServices.validSession(req)) {
                                return html.form({method:'post', action:qacServices.rootUrl}, [html.table(all_trs)]);
                            } else {
                                return html.table(all_trs);
                            }
            Severity: Major
            Found in lib/qac-services.js and 1 other location - About 1 hr to fix
            lib/qac-services.js on lines 419..423

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 67.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                            if(qacServices.validSession(req)) {
                                return html.form({method:'post', action:qacServices.rootUrl}, [html.table(all_trs)]);
                            } else {
                                return html.table(all_trs);
                            }
            Severity: Major
            Found in lib/qac-services.js and 1 other location - About 1 hr to fix
            lib/qac-services.js on lines 297..301

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 67.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function enableLoginPlus has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            qacServices.enableLoginPlus = function enableLoginPlus(usersDatabasePath) {
                if(! usersDatabasePath) {
                    throw new Error('must provide path to users database');
                }
                if(! fs.existsSync(usersDatabasePath)) {
            Severity: Minor
            Found in lib/qac-services.js - About 1 hr to fix

              Function getProjectPage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              qacServices.getProjectPage = function getProjectPage(req, organization, project){
                  var pageCont;
                  var info;
                  return qacServices.getInfo(organization, project).then(function(nfo) {
                      info = nfo;
              Severity: Minor
              Found in lib/qac-services.js - About 1 hr to fix

                Function getAdminPage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                qacServices.getAdminPage = function getAdminPage(req){
                    var newOrgTR = html.tr([html.td({colspan:2, "class":'right-align'}, qacServices.orgAddButton(req))]);
                    return qacServices.getOrganizations().then(function(orgs) {
                        if(orgs.length) {
                            return Promise.all(orgs.map(function(org) {
                Severity: Minor
                Found in lib/qac-services.js - About 1 hr to fix

                  Function projectServe has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  qacServices.projectServe = function projectServe(){
                      var thisModule = this;
                      return app.get(thisModule.rootUrl+':organization/:project',function(req,res,next){
                          if(qacServices.uriIsHandled(req)) {
                              return next();
                  Severity: Minor
                  Found in lib/qac-services.js - About 1 hr to fix

                    Function actualizeRepo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function actualizeRepo(repo, res, timestamp, isManual){
                        var info;
                        var feedback = isManual ? new Feedback(res) : new NoFeedback();
                        var bitacora;
                        qacServices.getInfo(repo.organization, repo.name).then(function(nfo) {
                    Severity: Minor
                    Found in lib/qac-services.js - About 1 hr to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              return fs.stat(info.organization.path).catch(function(err) {
                                  if(err.code==='ENOENT') {
                                      var err2=new Error('inexistent organization "'+organization+'"');
                                      err2.statusCode=404;
                                      throw err2;
                      Severity: Major
                      Found in lib/qac-services.js and 1 other location - About 1 hr to fix
                      lib/qac-services.js on lines 811..818

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 59.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              return fs.readdir(repoPath).catch(function(err) {
                                  if(err.code==='ENOENT') {
                                      var err2 = new Error('inexistent repository "'+repoPath+'"');
                                      err2.statusCode=404;
                                      throw err2;
                      Severity: Major
                      Found in lib/qac-services.js and 1 other location - About 1 hr to fix
                      lib/qac-services.js on lines 149..156

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 59.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Function getOrganizationPage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      qacServices.getOrganizationPage = function getOrganizationPage(req, organization){
                          return qacServices.getInfo(organization).then(function(info) {
                              if(info.organization.projects.length) {
                                  return Promise.all(info.organization.projects.map(function(project) {
                                      return qacServices.getProject(req, info, project);
                      Severity: Minor
                      Found in lib/qac-services.js - About 1 hr to fix

                        Function handleAbms has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function handleAbms(thisModule, url, method, pref) {
                            this.url = url;
                            this.handle = function(req, res, next) {
                                var vars = method === 'post' ? req.body : req.params;
                                if(req.session===undefined){
                        Severity: Minor
                        Found in lib/qac-services.js - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function createOrganization has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        qacServices.createOrganization = function createOrganization(name) {
                            var orgPath = Path.normalize(qacServices.repository.path+'/groups/'+name);
                            var dirs = [
                                Path.normalize(orgPath+'/params'),
                                Path.normalize(orgPath+'/projects')
                        Severity: Minor
                        Found in lib/qac-services.js - About 1 hr to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              this.logAll = function(type, data) {
                                  this.data.push({date:this.now(), type:type, data:data});
                              };
                          Severity: Major
                          Found in lib/qac-services.js and 1 other location - About 1 hr to fix
                          lib/qac-services.js on lines 448..450

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 56.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language