Flysoft-Studio/QQNTim

View on GitHub

Showing 25 of 36 total issues

Function patchBrowserWindow has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function patchBrowserWindow() {
    const windowMenu: Electron.MenuItem[] = [
        new MenuItem({
            label: "刷新",
            role: "reload",
Severity: Major
Found in src/main/patch.ts - About 4 hrs to fix

    Function isPluginRequirementsMet has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function isPluginRequirementsMet(manifest: QQNTim.Manifest) {
        if (manifest.requirements?.os) {
            let meetRequirements = false;
            const osRelease = os.release();
            for (const item of manifest.requirements.os) {
    Severity: Minor
    Found in src/main/plugins.ts - About 3 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 construct has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            construct(target, [options]: [Electron.BrowserWindowConstructorOptions]) {
                let patchedArgs: Electron.BrowserWindowConstructorOptions = {
                    ...options,
                    webPreferences: {
                        ...options.webPreferences,
    Severity: Major
    Found in src/main/patch.ts - About 3 hrs to fix

      Function interruptIpc has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function interruptIpc(args: QQNTim.IPC.Args<any>, direction: QQNTim.IPC.Direction, channel: string, sender?: Electron.WebContents) {
          for (const [func, options] of interruptIpcs) {
              if (options?.cmdName && (!args[1] || (args[1][0]?.cmdName != options?.cmdName && args[1][0] != options?.cmdName))) continue;
              if (options?.eventName && !args[0]?.eventName?.startsWith(`${options?.eventName}-`)) continue;
              if (options?.type && (!args[0] || args[0].type != options?.type)) continue;
      Severity: Minor
      Found in src/common/ipc.ts - 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 patchBrowserWindow has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function patchBrowserWindow() {
          const windowMenu: Electron.MenuItem[] = [
              new MenuItem({
                  label: "刷新",
                  role: "reload",
      Severity: Minor
      Found in src/main/patch.ts - 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

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

                  return new Proxy(win, {
                      get(target, p) {
                          const res = getter(undefined, target, p as any);
                          if (p == "webContents") return webContents;
                          return res;
      Severity: Major
      Found in src/main/patch.ts and 1 other location - About 1 hr to fix
      src/main/patch.ts on lines 97..106

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

      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

                  const webContents = new Proxy(win.webContents, {
                      get(target, p) {
                          const res = getter(undefined, target, p as any);
                          if (p == "session") return session;
                          return res;
      Severity: Major
      Found in src/main/patch.ts and 1 other location - About 1 hr to fix
      src/main/patch.ts on lines 143..152

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

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

      async function installPluginsForAccount(uin: string, requiresRestart: boolean, dir: string) {
          const manifestFiles = await collectManifests(dir);
          if (manifestFiles.length == 0) {
              await dialog.alert("未在目标文件夹或文件夹搜索到任何插件。\n请联系插件作者以获得更多信息。");
              return false;
      Severity: Minor
      Found in src/builtins/settings/src/installer.ts - 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 parsePlugin has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function parsePlugin(dir: string) {
          try {
              const manifestFile = `${dir}${s}qqntim.json`;
              if (!fs.existsSync(manifestFile)) return null;
              const manifest = fs.readJSONSync(manifestFile) as QQNTim.Manifest;
      Severity: Minor
      Found in src/main/plugins.ts - About 1 hr to fix

        Function prepareImageElement has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public async prepareImageElement(file: string) {
                const type = await ntCall("ns-fsApi", "getFileType", [file]);
                const md5 = await ntCall("ns-fsApi", "getFileMd5", [file]);
                const fileName = `${md5}.${type.ext}`;
                const filePath = await ntCall("ns-ntApi", "nodeIKernelMsgService/getRichMediaFilePath", [
        Severity: Minor
        Found in src/renderer/api/nt/media.ts - About 1 hr to fix

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

          export function destructFaceElement(element: QQNTim.API.Renderer.NT.MessageElementFace) {
              return {
                  elementType: 6,
                  elementId: "",
                  faceElement: {
          Severity: Minor
          Found in src/renderer/api/nt/destructor.ts - 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 constructMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export function constructMessage(msg: any): QQNTim.API.Renderer.NT.Message {
              const downloadedPromises: Promise<void>[] = [];
              const elements = (msg.elements as any[]).map((ele): QQNTim.API.Renderer.NT.MessageElement => {
                  if (ele.elementType == 1) return constructTextElement(ele);
                  else if (ele.elementType == 2) {
          Severity: Minor
          Found in src/renderer/api/nt/constructor.ts - About 45 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 parsePlugin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export function parsePlugin(dir: string) {
              try {
                  const manifestFile = `${dir}${s}qqntim.json`;
                  if (!fs.existsSync(manifestFile)) return null;
                  const manifest = fs.readJSONSync(manifestFile) as QQNTim.Manifest;
          Severity: Minor
          Found in src/main/plugins.ts - About 45 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 3 locations. Consider refactoring.
          Open

              messageBox(options: Electron.MessageBoxOptions): Promise<Electron.MessageBoxReturnValue> {
                  return ipcRenderer.invoke("___!dialog", "showMessageBox", options);
              }
          Severity: Minor
          Found in src/renderer/api/dialog.ts and 2 other locations - About 40 mins to fix
          src/renderer/api/dialog.ts on lines 18..20
          src/renderer/api/dialog.ts on lines 22..24

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

          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 3 locations. Consider refactoring.
          Open

              openDialog(options: Electron.OpenDialogOptions): Promise<Electron.OpenDialogReturnValue> {
                  return ipcRenderer.invoke("___!dialog", "showOpenDialog", options);
              }
          Severity: Minor
          Found in src/renderer/api/dialog.ts and 2 other locations - About 40 mins to fix
          src/renderer/api/dialog.ts on lines 14..16
          src/renderer/api/dialog.ts on lines 22..24

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

          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 3 locations. Consider refactoring.
          Open

              saveDialog(options: Electron.SaveDialogOptions): Promise<Electron.SaveDialogReturnValue> {
                  return ipcRenderer.invoke("___!dialog", "showSaveDialog", options);
              }
          Severity: Minor
          Found in src/renderer/api/dialog.ts and 2 other locations - About 40 mins to fix
          src/renderer/api/dialog.ts on lines 14..16
          src/renderer/api/dialog.ts on lines 18..20

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

          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 enablePlugin has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export function enablePlugin(setConfig: React.Dispatch<React.SetStateAction<Required<QQNTim.Configuration>>>, id: string, enable: boolean, inWhitelist: boolean, inBlacklist: boolean) {
          Severity: Minor
          Found in src/builtins/settings/src/utils/utils.ts - About 35 mins to fix

            Function loadPlugins has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function loadPlugins(allPlugins: QQNTim.Plugin.AllUsersPlugins, uin: string, shouldInject: (injection: QQNTim.Plugin.Injection) => boolean, scripts: [QQNTim.Plugin, string][], stylesheets?: [QQNTim.Plugin, string][]) {
            Severity: Minor
            Found in src/common/loader.ts - About 35 mins to fix

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

              export function constructFaceElement(ele: any): QQNTim.API.Renderer.NT.MessageElementFace {
                  return {
                      type: "face",
                      faceIndex: ele.faceElement.faceIndex,
                      faceType: ele.faceElement.faceType == 1 ? "normal" : ele.faceElement.faceType == 2 ? "normal-extended" : ele.faceElement.faceType == 3 ? "super" : ele.faceElement.faceType,
              Severity: Minor
              Found in src/renderer/api/nt/constructor.ts - 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 Panel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function Panel({ currentTab, account }: { currentTab: TabWithOtherTab; account: QQNTim.API.Renderer.NT.LoginAccount }) {
                  const [config, setConfig] = useState<Required<QQNTim.Configuration>>(env.config);
                  const [pluginsConfig, setPluginsConfig] = useState<Record<string, object>>(config.plugins.config || {});
              
                  const saveConfigAndRestart = () => {
              Severity: Minor
              Found in src/builtins/settings/src/panel.tsx - 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

              Severity
              Category
              Status
              Source
              Language