Showing 14 of 42 total issues
Function LinkShortener
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function LinkShortener() {
const [isOpen, setIsOpen] = useState(false)
const notify = useNotify()
const {
loading: permissionsLoading,
Function EditComponent
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
const EditComponent = props => {
const { loading, permissions } = usePermissions()
const resource = subject('Link', props.record)
return loading ? (
Function QueryBuilder
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
static get QueryBuilder() {
return class extends super.QueryBuilder {
insertAndFetch(body) {
const q = this.insert(body).returning('*')
return Array.isArray(body) ? q : q.first()
- 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 verify
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
exports.verify = (scopeStr, requiredScope) => {
return scopeStr.split(' ').some(scope => {
if (scope.includes('*')) {
// There's a * to expand; given that each section is separated by a colon,
// try to expand it and see if it fits
- 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 QueryBuilder
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get QueryBuilder() {
return class extends super.QueryBuilder {
insertAndFetch(body) {
const q = this.insert(body).returning('*')
return Array.isArray(body) ? q : q.first()
Function App
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function App() {
// theme that changes to dark mode according to system settings
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)')
const theme = useMemo(
() =>
Function EditComponent
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
const EditComponent = props => {
const { loading, permissions } = usePermissions()
const resource = subject('User', props.record)
return loading ? (
Function seed
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
exports.seed = async knex => {
option({ random: require('seedrandom')('Some seed') })
const links = []
const schema = deepCopy(globalSchema.Link)
- 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 exports
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (err, req, res, next) => {
if (res.headersSent) {
req.log.error(err, 'An error occurred after request was sent')
return
}
Function $parseJson
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
$parseJson(originalJSON, opt) {
const json = deepCopy(super.$parseJson(originalJSON, opt))
if (json.hash) {
// Since custom and auto-generated hash are both mounted under /,
- 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 registerValidSW
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
Function paginate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
paginate(query = {}) {
// defaults
let page = 0
let pageSize = 25 // this covers cases where you need to fetch by id up to 25 items
let column = 'id'
Function seed
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.seed = async knex => {
option({ random: require('seedrandom')('Some seed') })
const links = []
const schema = deepCopy(globalSchema.Link)
Function exports
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = async url => {
const requestLogger = logger.child({ url })
requestLogger.info(`Scraping %s for metadata...`, url)
try {
- 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"