undergroundwires/privacy.sexy

View on GitHub

Showing 35 of 42 total issues

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

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

WindowScrollDomState has 26 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

    export class SyntaxFactory
      extends ScriptingLanguageFactory<ILanguageSyntax>
      implements ISyntaxFactory {
      constructor() {
        super();
    src/application/Context/State/Code/Generation/CodeBuilderFactory.ts on lines 8..16

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

    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 26..36

        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 21..31

        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 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 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 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,
            ) {
            Severity: Minor
            Found in src/presentation/components/Scripts/Slider/UseDragHandler.ts - About 1 hr to fix

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

                public getScript(scriptId: string): IScript {
                  const script = this.queryable.allScripts.find((s) => s.id === scriptId);
                  if (!script) {
                    throw new Error(`missing script: ${scriptId}`);
                  }
              Severity: Major
              Found in src/domain/CategoryCollection.ts and 1 other location - About 1 hr to fix
              src/domain/CategoryCollection.ts on lines 29..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 67.

              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(categoryId: number): ICategory {
                  const category = this.queryable.allCategories.find((c) => c.id === categoryId);
                  if (!category) {
                    throw new Error(`Missing category with ID: "${categoryId}"`);
                  }
              Severity: Major
              Found in src/domain/CategoryCollection.ts and 1 other location - About 1 hr to fix
              src/domain/CategoryCollection.ts on lines 43..49

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

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

                  Function interpretShellOutcome has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function interpretShellOutcome(
                    outcome: ShellCommandOutcome,
                    commandDefinition: CommandDefinition,
                  ): ScriptFileExecutionOutcome {
                    switch (outcome.type) {
                    Severity
                    Category
                    Status
                    Source
                    Language