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;
- Read upRead up
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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,
- Read upRead up
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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 = {
- Create a ticketCreate a ticket
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());
- Create a ticketCreate a ticket
Function processDashboard
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function processDashboard(
allJobs: string[],
dashboardName: string,
dashboardConfig: IDashboardConfig,
filters: IFilters,
- Create a ticketCreate a ticket
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);
}
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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);
- Create a ticketCreate a ticket
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)) {
- Create a ticketCreate a ticket
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) => {
- Read upRead up
- Create a ticketCreate a ticket
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]
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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]
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76