jameswlane/status-board

View on GitHub

Showing 112 of 112 total issues

Function start has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  public start() {
    // tslint:disable-next-line no-this-assignment
    const self = this;
    const job = self.jobWorker;

Severity: Minor
Found in src/Scheduler.ts - About 3 hrs 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 getByPackage has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getByPackage(packagesPath: string | string[],
                             itemType: string,
                             extension: string,
                             callback: any) {
  let processedPackagePath;
Severity: Major
Found in src/item-manager/get-by-package.ts - About 2 hrs to fix

Function processDashboard has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function processDashboard(
  allJobs: string[],
  dashboardName: string,
  dashboardConfig: IDashboardConfig,
  filters: IFilters,
Severity: Minor
Found in src/job-manager/process-dashboard.ts - About 2 hrs 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 getJobs has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getJobs(options: IJobOptions, callback: IVoidCallbackWithData) {
  const packagesPath = options.packagesPath;
  const filters = options.filters || {};

  const configPath = path.join(options.configPath, '/dashboard_common.json');
Severity: Major
Found in src/job-manager/get-jobs.ts - About 2 hrs to fix

Function start has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public start() {
    // tslint:disable-next-line no-this-assignment
    const self = this;
    const job = self.jobWorker;

Severity: Major
Found in src/Scheduler.ts - About 2 hrs to fix

Function default has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (jobWorker: any) {
  function addAuthConfig(auth: any, opts: any) {
    const authData = jobWorker.config.globalAuth[auth];
    if (authData && authData.username && authData.password) {
      opts.auth = {
Severity: Major
Found in src/job-dependencies/experimentalConfluence/dependency.ts - About 2 hrs to fix

Function globalAuth has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function globalAuth(file: string) {
  let auth = {};

  try {
    auth = JSON.parse(fs.readFileSync(file).toString());
Severity: Minor
Found in src/global-auth.ts - About 1 hr to fix

Function processDashboard has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function processDashboard(
  allJobs: string[],
  dashboardName: string,
  dashboardConfig: IDashboardConfig,
  filters: IFilters,
Severity: Minor
Found in src/job-manager/process-dashboard.ts - About 1 hr to fix

Function init has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function init(options: IJobOptions, cb: (error?: any) => void) {
  getJobs(options, (err: any, jobWorkers: IJob[]) => {
    if (err) {
      return cb(err);
    }
Severity: Minor
Found in src/job-initialiser.ts - About 1 hr to fix

Function routes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function routes(app: Application, packagesPath: any) {
  const wallboardAssetsFolder = path.join(process.cwd(), 'assets');

  // -----------------------------------------
  //  Log
Severity: Minor
Found in src/webapp/routes.ts - About 1 hr to fix

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

export function renderJsDashboard(packagesPath: any,
                                  wallboardAssetsFolder: any,
                                  dashboardName: any,
                                  request: Request,
                                  response: Response) {
Severity: Minor
Found in src/webapp/logic.ts - About 1 hr to fix

Function create has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function create(options: any) {
  const request = options.request || require('request');

  if (!options.api_key) {
    logger.error('api_key required');
Severity: Minor
Found in src/job-dependencies/hipchat/hipchat.ts - About 1 hr to fix

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

export function runner(
  options: IOptions,
  callback: IVoidCallbackWithError,
) {
  const packagesLocalFolder = path.join(process.cwd(), '/packages');
Severity: Minor
Found in src/runner.ts - About 1 hr to fix

Function bindWidget has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function bindWidget(io, $li) {
    var widgetId = encodeURIComponent($li.attr("data-widget-id"));
    var eventId = $li.attr("data-event-id");

    var $widgetContainer = $("<div>").addClass("widget-container").appendTo($li).hide();
Severity: Minor
Found in assets/javascripts/application.js - About 1 hr to fix

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

export function listAllDashboards(packagesPath: any, request: Request, response: Response) {
  get(packagesPath, 'dashboards', '.json', (getError: any, dashboardConfigFiles: string[]) => {
    if (getError) {
      logger().error(getError);
      return response.status(400).send('Error loading dashboards');
Severity: Minor
Found in src/webapp/routes/dashboard.ts - About 1 hr to fix

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

export function renderDashboard(packagesPath: any,
                                dashboardName: any,
                                request: Request,
                                response: Response) {
  const safeDashboardName = getSafeItemName(dashboardName);
Severity: Minor
Found in src/webapp/routes/dashboard.ts - About 1 hr to fix

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

  function readItemsFromPackageDir(dir: any, cb: any) {
    const packages: any = { dir };

    const itemDir = path.join(dir, itemType);
    if (!fs.existsSync(itemDir)) {
Severity: Minor
Found in src/item-manager/get-by-package.ts - About 1 hr to fix

Function default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export default function (config: any) {
  const client = new Client(config);

  return {
    query: (connectionString: any, query: any, params: any, callback: any) => {
Severity: Minor
Found in src/job-dependencies/postgreSQL/dependency.ts - About 55 mins 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

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

    onData: function () {
      atlasboard.triggerEvent("widgetData", {
        $widgetContainer: arguments[0],
        data: arguments[1],
        widgetId: arguments[2]
Severity: Minor
Found in assets/javascripts/application.js and 1 other location - About 50 mins to fix
assets/javascripts/application.js on lines 42..48

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 52.

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

    onError: function () {
      atlasboard.triggerEvent("widgetError", {
        $errorContainer: arguments[0],
        data: arguments[1],
        widgetId: arguments[2]
Severity: Minor
Found in assets/javascripts/application.js and 1 other location - About 50 mins to fix
assets/javascripts/application.js on lines 57..63

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 52.

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