xcv58/Custom-JavaScript-for-Websites-2

View on GitHub

Showing 5 of 12 total issues

AppStore has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class AppStore {
  store: Store

  constructor (store) {
    makeObservable(this, {
Severity: Minor
Found in src/js/stores/AppStore.tsx - About 3 hrs to fix

    File AppStore.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { action, computed, observable, makeObservable } from 'mobx'
    import { encodeSource, decodeSource, getHosts, setHosts } from 'libs'
    import isEqual from 'lodash.isequal'
    import sizeof from 'object-sizeof'
    import { js } from 'js-beautify'
    Severity: Minor
    Found in src/js/stores/AppStore.tsx - About 2 hrs to fix

      Function NewPatternDialog has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const NewPatternDialog = observer(() => {
        const navigate = useNavigate()
        const { NewPatternStore } = useStore()
        const { closeDialog, error, validPattern, pattern } = NewPatternStore
        return (
      Severity: Minor
      Found in src/js/components/NewPattern.tsx - About 1 hr to fix

        Function constructor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor (store) {
            makeObservable(this, {
              mode: observable,
              loading: observable,
              autoSaveHandle: observable,
        Severity: Minor
        Found in src/js/stores/AppStore.tsx - About 1 hr to fix

          Function onMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          const onMessage = async (message, sender, sendResponse) => {
            const { domain } = message
            try {
              const tab = await getActiveTab()
              const url = domain ? getURL({ url: domain }) : getURL(tab)
          Severity: Minor
          Found in src/js/background.tsx - About 25 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