sandworm-hq/sandworm-js

View on GitHub

Showing 31 of 31 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <ul className="flex gap-4 text-neutral-400">
        <li
          className={classNames('cursor-pointer', {
            'font-bold text-neutral-200 border-b-2': selectedLibrary === 'web',
          })}
Severity: Major
Found in cli/frontend/src/components/Permissions.jsx and 1 other location - About 4 hrs to fix
cli/frontend/src/index.js on lines 36..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 115.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          <ul className="flex gap-10 text-neutral-300 text-xl">
            <li
              className={classNames('cursor-pointer', {
                'font-bold text-neutral-200 border-b-2': currentTab === 'permissions',
              })}
Severity: Major
Found in cli/frontend/src/index.js and 1 other location - About 4 hrs to fix
cli/frontend/src/components/Permissions.jsx on lines 31..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 115.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                      {modules.length > 1 && (
                        <div className="text-zinc-400 text-xs">
                          via{' '}
                          {modules
                            .slice(1)
    Severity: Major
    Found in cli/frontend/src/components/Modules.jsx and 1 other location - About 3 hrs to fix
    cli/frontend/src/components/Title.jsx on lines 6..14

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          {modules.length > 1 && (
            <div className="text-zinc-400 text-xs">
              via{' '}
              {modules
                .slice(1)
    Severity: Major
    Found in cli/frontend/src/components/Title.jsx and 1 other location - About 3 hrs to fix
    cli/frontend/src/components/Modules.jsx on lines 39..47

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            eventSubscribers.forEach((subscriber) => {
                              const message = `retry:${refreshRate}\nid:${Date.now()}\ndata:${JSON.stringify(
                                processedEvents,
                              )}\n\n`;
                              subscriber.write(message);
                Severity: Minor
                Found in cli/index.js and 1 other location - About 55 mins to fix
                cli/index.js on lines 164..169

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 53.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      try {
                        const message = `retry:${refreshRate}\nid:${Date.now()}\ndata:${JSON.stringify(
                          history,
                        )}\n\n`;
                        response.write(message);
                Severity: Minor
                Found in cli/index.js and 1 other location - About 55 mins to fix
                cli/index.js on lines 134..139

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 53.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language