sandworm-hq/sandworm-js

View on GitHub

Showing 20 of 31 total issues

Function server has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const server = http.createServer((request, response) => {
  switch (request.url) {
    // Serve the frontend React app
    case '/':
      serve(response, ['index.html']);
Severity: Major
Found in cli/index.js - About 3 hrs to fix

    Function init has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    const init = ({
      loadSourceMaps = currentPlatform === PLATFORMS.WEB,
      devMode: devModeOption = false,
      verbose = false,
      skipTracking: skipTrackingOption = false,
    Severity: Minor
    Found in src/index.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 Activity has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Activity = () => {
      const [selected, setSelected] = useState(null);
      const {history, selectedModule} = useContext(DataContext);
      const moduleHistory = useMemo(
        () => (history || []).filter((e) => e?.module === selectedModule),
    Severity: Major
    Found in cli/frontend/src/components/Activity.jsx - About 2 hrs to fix

      Function buildPatch has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      const buildPatch = (family, method, track = () => {}) =>
        // eslint-disable-next-line func-names
        function (...args) {
          let allowed;
          const {
      Severity: Minor
      Found in src/patch.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 sendBatch has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const sendBatch = () => {
        try {
          if (skipTracking || batch.length === 0) {
            return;
          }
      Severity: Major
      Found in src/track.js - About 2 hrs to fix

        Function Permissions has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Permissions = () => {
          const [selectedLibrary, setSelectedLibrary] = useState(null);
          const {
            requiredPermissions,
            selectedModule,
        Severity: Major
        Found in cli/frontend/src/components/Permissions.jsx - About 2 hrs to fix

          Function App has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function App() {
            const {history, setHistory, currentTab, setCurrentTab, selectedModule} = useContext(DataContext);
          
            useEffect(() => {
              const evtSource = new EventSource('/events');
          Severity: Major
          Found in cli/frontend/src/index.js - About 2 hrs to fix

            Function sendBatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            export const sendBatch = () => {
              try {
                if (skipTracking || batch.length === 0) {
                  return;
                }
            Severity: Minor
            Found in src/track.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 parseStackLine has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const parseStackLine = (l) => {
              const line = (l || '').trim();
            
              const cached = lineParseCache[line];
              if (cached) {
            Severity: Minor
            Found in src/stack.js - About 1 hr to fix

              Function getSourceMapFromSource has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const getSourceMapFromSource = async (location) => {
                try {
                  logger.debug(`loading source from ${location}`);
                  const source = await getSource(location);
              
              
              Severity: Minor
              Found in src/source.js - About 1 hr to fix

                Function DataProvider has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                export const DataProvider = ({children}) => {
                  const [currentTab, setCurrentTab] = useLocalStorage('_sandworm_permissions', 'permissions');
                  const [history, setHistory] = useState([]);
                  const [selectedModule, setSelectedModule] = useLocalStorage('_sandworm_module', null);
                  const [requiredPermissions, setRequiredPermissions] = useState({});
                Severity: Minor
                Found in cli/frontend/src/context.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 getSourceMapFromSource has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                export const getSourceMapFromSource = async (location) => {
                  try {
                    logger.debug(`loading source from ${location}`);
                    const source = await getSource(location);
                
                
                Severity: Minor
                Found in src/source.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 parseStackLine has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                export const parseStackLine = (l) => {
                  const line = (l || '').trim();
                
                  const cached = lineParseCache[line];
                  if (cached) {
                Severity: Minor
                Found in src/stack.js - About 55 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

                Function getModuleNameFromLocation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                export const getModuleNameFromLocation = (location, allowURLs) => {
                  // Infer the module name
                  let moduleName = 'root';
                
                  if (!location || typeof location !== 'string') {
                Severity: Minor
                Found in src/module.js - About 55 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

                Consider simplifying this complex logical expression.
                Open

                  if (
                    (match = line.match(/at (.+) \(eval at .+ \((.+)\), .+\)/)) || // eval calls
                    (match = line.match(/at (.+) \((.+)\)/)) ||
                    (line.slice(0, 3) !== 'at ' && (match = line.match(/(.*)@(.*)/)))
                  ) {
                Severity: Major
                Found in src/stack.js - About 40 mins to fix

                  Function node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const node = ({name, methods, globalMethod}) => {
                    let module;
                    if (!globalMethod) {
                      try {
                        // eslint-disable-next-line no-undef
                  Severity: Minor
                  Found in src/library/builder.js - About 35 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

                  Function web has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const web = ({
                    name,
                    globalConstructor,
                    constructorDescription,
                    constructorUrl,
                  Severity: Minor
                  Found in src/library/builder.js - About 35 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

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

                  const server = http.createServer((request, response) => {
                    switch (request.url) {
                      // Serve the frontend React app
                      case '/':
                        serve(response, ['index.html']);
                  Severity: Minor
                  Found in cli/index.js - 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

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

                  export const getCurrentModuleInfo = ({stack: stackInput, allowURLs = false} = {}) => {
                    try {
                      const stack = (stackInput || currentStack())
                        // If we have sourcemap info, trace calls back to the original files
                        .map((item) => mapStackItemToSource(item, sourcemaps))
                  Severity: Minor
                  Found in src/module.js - 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

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

                  function useLocalStorage(key, initialValue) {
                    // State to store our value
                    // Pass initial state function to useState so logic is only executed once
                    const [storedValue, setStoredValue] = useState(() => {
                      if (typeof window === 'undefined') {
                  Severity: Minor
                  Found in cli/frontend/src/hooks/useLocalStorage.js - 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