Showing 90 of 251 total issues
Function Sidebar
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Open
export const Sidebar = ({
snippets,
filterText,
filterTags,
filterLanguage,
- 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 createWindow
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const createWindow = () => {
log.transports.file.level = 'debug';
autoUpdater.logger = log;
autoUpdater.checkForUpdatesAndNotify();
File snippets.js
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
merge,
keyBy,
update,
set,
Function render
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { data } = this.props;
const menu = (
<React.Fragment>
Function responseHandler
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const responseHandler = (error, result, dispatch, action) => {
if (error) {
if (error.response && error.response.headers['x-github-otp']) {
setNotification({
title: 'Two factor authentication',
Function render
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { file, username, snippetId, edit, toggleCollapse, theme } = this.props;
const openOnWebUrl = `${getSnippetUrl('/gist')}/${username}/${snippetId}#file-${file.filename}`;
return (
Function snippets
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
export const snippets = (state = initialState, action) => {
switch (action.type) {
case AT.GET_SNIPPETS.SUCCESS: {
const lastUpdated = state.lastUpdated === null ? toISOString() : state.lastUpdated;
- 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 render
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
snippets,
filterText,
filterTags,
Function render
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { comments, showComments, snippetId, deleteComment, theme } = this.props;
return (
<CommentsWrapper show={ showComments }>
Function handleMacOSUpdates
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function handleMacOSUpdates(mainWindow) {
if (isMacOS) {
const LATEST_RELEASED_VERSION_URL = 'https://api.github.com/repos/Gisto/Gisto/releases/latest';
const request = require('superagent');
const semver = require('semver');
Function searchType
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const searchType = () => {
if (!isEmpty(trim(filterText))) {
return isTag(filterText) ? 'free text tag' : 'free text';
}
Function prepareFilesForUpdate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const prepareFilesForUpdate = (snippet: ISnippet) => {
const cleanFiles = flow([
map((file) => {
return pick(['filename', 'content', 'originalFileName', 'delete', 'isNew'], file);
}),
Function updateChecker
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateChecker(mainWindow) {
ipcMain.on('downloadUpdate', () => autoUpdater.downloadUpdate());
ipcMain.on('quitAndInstall', () => autoUpdater.quitAndInstall(true, true));
autoUpdater.logger = log;
Function componentDidMount
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
componentDidMount() {
if (!sessionStorage.getItem('gistoReleases')) {
fetch('https://api.github.com/repos/Gisto/Gisto/releases/latest')
.then((response) => response.json())
.then((data) => {
Function render
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { snippet, edit, tempSnippet, showComments, addTempFile } = this.props;
const currentSnippet = edit ? tempSnippet : snippet;
const files = filter((file) => !file.delete, get('files', currentSnippet));
Function handleDownload
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function handleDownload(win) {
win.webContents.session.on('will-download', (event, item, sender) => {
const isUpdateUrl = includes(
['https://github.com/Gisto/Gisto/releases/download/'],
head(item.getURLChain())
Function render
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { lightText, colorDanger } = this.props.theme;
const {
children,
size = 22,
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<Wrapper>
<img src={ logoImg } width="80" alt=""/>
<h2>About Gisto</h2>
Function filterByFreeText
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const filterByFreeText = (snippets: ISnippet, filterText: string) => {
try {
new RegExp(filterText, 'gi');
} catch (e) {
return false;
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { theme, user, logout } = this.props;
const { login, avatar_url: avatar } = user;
return (