Showing 148 of 148 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (options.packager.platform === 'linux') {
if (iconIsPng(options.packager.icon)) {
log.debug(
'Building for Linux and icon is already a .png, no conversion needed',
);
- Read upRead up
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 115.
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
Function buildNativefierApp
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function buildNativefierApp(
rawOptions: RawOptions,
): Promise<string> {
// early-suppress potential logging before full options handling
if (rawOptions.quiet) {
File playwright-test.ts
has 325 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { once } from 'events';
import * as fs from 'fs';
import * as path from 'path';
import { Shell } from 'electron';
Function setupScreenSharePickerStyles
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupScreenSharePickerStyles(id: string): void {
const screenShareStyles = document.createElement('style');
screenShareStyles.id = id;
screenShareStyles.innerHTML = `
.desktop-capturer-selection {
File windowEvents.test.ts
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
jest.mock('./helpers');
jest.mock('./windowEvents');
jest.mock('./windowHelpers');
import { dialog, BrowserWindow, HandlerDetails, WebContents } from 'electron';
File windowHelpers.ts
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
import path from 'path';
import {
dialog,
BrowserWindow,
Function createMainWindow
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function createMainWindow(
nativefierOptions: OutputOptions,
setDockBadge: (value: number | string, bounce?: boolean) => void,
): Promise<BrowserWindow> {
const options = { ...nativefierOptions };
Function pickElectronAppArgs
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
function pickElectronAppArgs(options: AppOptions): OutputOptions {
return {
accessibilityPrompt: options.nativefier.accessibilityPrompt,
alwaysOnTop: options.nativefier.alwaysOnTop,
appBundleId: options.packager.appBundleId,
File helpers.test.ts
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { shell } from 'electron';
jest.mock('./windowHelpers');
import {
cleanupPlainText,
Function generateMenu
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export function generateMenu(
options: {
disableDevTools: boolean;
nativefierVersion: string;
zoom?: number;
- Read upRead up
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
File preload.ts
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Preload file that will be executed in the renderer process.
* Note: This needs to be attached **prior to imports**, as imports
* would delay the attachment till after the event has been raised.
*/
File cli.test.ts
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
import 'source-map-support/register';
import { initArgs, parseArgs } from './cli';
import { parseJson } from './utils/parseUtils';
Function onReady
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function onReady(): Promise<void> {
// Warning: `mainWindow` below is the *global* unique `mainWindow`, created at init time
mainWindow = await createMainWindow(appArgs, setDockBadge);
createTrayIcon(appArgs, mainWindow);
Function spawnApp
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
const spawnApp = async (
playwrightConfig: NativefierOptions = { ...DEFAULT_CONFIG },
awaitFirstWindow = true,
preventNavigation = false,
): Promise<Page | undefined> => {
Function buildNativefierApp
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export async function buildNativefierApp(
rawOptions: RawOptions,
): Promise<string> {
// early-suppress potential logging before full options handling
if (rawOptions.quiet) {
- Read upRead up
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 findSync
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function findSync(
pattern: RegExp,
basePath: string,
limitSearchToDirectories = false,
): string[] {
- Read upRead up
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 createTrayIcon
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createTrayIcon(
nativefierOptions: OutputOptions,
mainWindow: BrowserWindow,
): Tray | undefined {
const options = { ...nativefierOptions };
File mainWindow.ts
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as fs from 'fs';
import * as path from 'path';
import {
desktopCapturer,
Function getAllowedIconFormats
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export function getAllowedIconFormats(platform: string): string[] {
const hasIdentify = hasbin.sync('identify') || hasbin.sync('gm');
const hasConvert = hasbin.sync('convert') || hasbin.sync('gm');
const hasIconUtil = hasbin.sync('iconutil');
- Read upRead up
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
test('--help forces exit', () => {
// Mock console.log to not pollute the log with the yargs help text
const mockLog = jest.spyOn(console, 'log').mockImplementation();
initArgs(['https://www.google.com', '--help']);
expect(mockExit).toHaveBeenCalledTimes(1);
- Read upRead up
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 86.
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