JaneJeon/myURL

View on GitHub

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,
Severity: Major
Found in src/components/shortener.js - About 6 hrs to fix

    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 ? (
    Severity: Major
    Found in src/resources/link.js - About 4 hrs to fix

      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()
      Severity: Minor
      Found in models/base.js - About 4 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 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
      Severity: Minor
      Found in lib/scope.js - 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 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()
      Severity: Minor
      Found in models/base.js - About 1 hr to fix

        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(
            () =>
        Severity: Minor
        Found in src/App.js - About 1 hr to fix

          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 ? (
          Severity: Minor
          Found in src/resources/user.js - About 1 hr to fix

            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)
            Severity: Minor
            Found in seeds/20210312221718_links.js - About 1 hr 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 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
              }
            Severity: Minor
            Found in middlewares/error-handler.js - About 1 hr to fix

              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 /,
              Severity: Minor
              Found in models/link.js - About 1 hr 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 registerValidSW has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function registerValidSW(swUrl, config) {
                navigator.serviceWorker
                  .register(swUrl)
                  .then(registration => {
                    registration.onupdatefound = () => {
              Severity: Minor
              Found in src/serviceWorker.js - About 1 hr to fix

                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'
                Severity: Minor
                Found in models/base.js - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in seeds/20210312221718_links.js - About 1 hr to fix

                    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 {
                    Severity: Minor
                    Found in lib/scrape.js - About 45 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

                    Severity
                    Category
                    Status
                    Source
                    Language