undergroundwires/privacy.sexy

View on GitHub

Showing 42 of 45 total issues

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

function shuffle(array: readonly string[]): string[] {
  const shuffledArray = [...array];
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
Severity: Major
Found in src/presentation/components/DevToolkit/DumpNames.ts and 1 other location - About 3 hrs to fix
src/application/Common/Shuffle.ts on lines 5..12

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 108.

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

export function shuffle<T>(array: readonly T[]): T[] {
  const shuffledArray = [...array];
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
Severity: Major
Found in src/application/Common/Shuffle.ts and 1 other location - About 3 hrs to fix
src/presentation/components/DevToolkit/DumpNames.ts on lines 28..35

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 108.

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

WindowScrollDomState has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class WindowScrollDomState implements ScrollDomStateAccessor {
  get bodyStyleOverflowX(): string { return BodyElement.style.overflowX; }

  set bodyStyleOverflowX(value: string) { BodyElement.style.overflowX = value; }

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

      public getScript(executableId: ExecutableId): Script {
        const script = this.queryable.allScripts.find((s) => s.executableId === executableId);
        if (!script) {
          throw new Error(`Missing script: ${executableId}`);
        }
    Severity: Major
    Found in src/domain/Collection/CategoryCollection.ts and 1 other location - About 2 hrs to fix
    src/domain/Collection/CategoryCollection.ts on lines 41..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 84.

    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

      public getCategory(executableId: ExecutableId): Category {
        const category = this.queryable.allCategories.find((c) => c.executableId === executableId);
        if (!category) {
          throw new Error(`Missing category with ID: "${executableId}"`);
        }
    Severity: Major
    Found in src/domain/Collection/CategoryCollection.ts and 1 other location - About 2 hrs to fix
    src/domain/Collection/CategoryCollection.ts on lines 55..61

    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 84.

    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

      public addArgument(argument: FunctionCallArgument): void {
        if (this.hasArgument(argument.parameterName)) {
          throw new Error(`argument value for parameter ${argument.parameterName} is already provided`);
        }
        this.arguments.set(argument.parameterName, argument);
    src/application/Parser/Executable/Script/Compiler/Function/SharedFunctionCollection.ts on lines 7..12

    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 78.

    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

      public addFunction(func: ISharedFunction): void {
        if (this.has(func.name)) {
          throw new Error(`function with name ${func.name} already exists`);
        }
        this.functionsByName.set(func.name, func);
    src/application/Parser/Executable/Script/Compiler/Function/Call/Argument/FunctionCallArgumentCollection.ts on lines 7..12

    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 78.

    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

    export class ShellBuilder extends CodeBuilder {
      protected getCommentDelimiter(): string {
        return '#';
      }
    
    
    src/application/Context/State/Code/Generation/Languages/BatchBuilder.ts on lines 3..15

    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 74.

    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

    export class BatchBuilder extends CodeBuilder {
      protected getCommentDelimiter(): string {
        return '::';
      }
    
    
    src/application/Context/State/Code/Generation/Languages/ShellBuilder.ts on lines 3..15

    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 74.

    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 useCollectionSelectionStateUpdater has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useCollectionSelectionStateUpdater(
      useSelectionStateHook: ReturnType<typeof useUserSelectionState>,
    ) {
      const { modifyCurrentSelection, currentSelection } = useSelectionStateHook;
    
    

      Function createAntivirusErrorDialog has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createAntivirusErrorDialog(
        information: ScriptErrorDetails,
        diagnostics: ScriptDiagnosticData | undefined,
      ): ErrorDialogParameters {
        const defenderSteps = generateDefenderSteps(information, diagnostics);
      Severity: Minor
      Found in src/presentation/components/Code/CodeButtons/ScriptErrorDialog.ts - About 1 hr to fix

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

          public selectWithRevertState(newState: boolean, selection: UserSelection): void {
            selection.scripts.processChanges({
              changes: [{
                scriptId: this.scriptId,
                newStatus: {
        src/presentation/components/Scripts/View/Tree/NodeContent/Reverter/CategoryReverter.ts on lines 28..38

        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 73.

        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

          public selectWithRevertState(newState: boolean, selection: UserSelection): void {
            selection.categories.processChanges({
              changes: [{
                categoryId: this.categoryId,
                newStatus: {
        src/presentation/components/Scripts/View/Tree/NodeContent/Reverter/ScriptReverter.ts on lines 23..33

        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 73.

        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 useCollectionSelectionStateUpdater has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        export function useCollectionSelectionStateUpdater(
          useSelectionStateHook: ReturnType<typeof useUserSelectionState>,
        ) {
          const { modifyCurrentSelection, currentSelection } = useSelectionStateHook;
        
        

        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 updateNodeSelection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function updateNodeSelection(change: TreeNodeStateChangedEmittedEvent) {
            const { node } = change;
            if (node.hierarchy.isBranchNode) {
              return; // A category, let TreeView handle this
            }

          Function parseWithExpressions has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function parseWithExpressions(input: string): IExpression[] {
            const allStatements = parseAllWithExpressions(input);
            const sortedStatements = allStatements
              .slice()
              .sort((a, b) => b.position.start - a.position.start);

            Function useDragHandler has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function useDragHandler(
              draggableElementRef: Readonly<Ref<HTMLElement | undefined>>,
              dragDomModifier: DragDomModifier = new GlobalDocumentDragDomModifier(),
              throttler = throttle,
              onTeardown: LifecycleHook = onUnmounted,
            Severity: Minor
            Found in src/presentation/components/Scripts/Slider/UseDragHandler.ts - About 1 hr to fix

              Function useCollectionState has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function useCollectionState(
                context: IApplicationContext,
                events: IEventSubscriptionCollection,
              ) {
                const currentState = shallowRef<IReadOnlyCategoryCollectionState>(context.state);
              Severity: Minor
              Found in src/presentation/components/Shared/Hooks/UseCollectionState.ts - About 1 hr to fix

                Function createGenericErrorDialog has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function createGenericErrorDialog(
                  information: ScriptErrorDetails,
                  diagnostics: ScriptDiagnosticData | undefined,
                ): ErrorDialogParameters {
                  return [
                Severity: Minor
                Found in src/presentation/components/Code/CodeButtons/ScriptErrorDialog.ts - About 1 hr to fix

                  Function parseWithExpressions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseWithExpressions(input: string): IExpression[] {
                    const allStatements = parseAllWithExpressions(input);
                    const sortedStatements = allStatements
                      .slice()
                      .sort((a, b) => b.position.start - a.position.start);

                  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