BuddhaNexus/buddhanexus

View on GitHub

Showing 439 of 439 total issues

Function get_folios_from_segment_keys has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

def get_folios_from_segment_keys(segment_keys, lang):
    folios = []
    if lang == LANG_CHINESE:
        last_num = ""
        for segment_key in segment_keys:            
Severity: Minor
Found in dataloader/folios.py - About 6 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 AppTopBar has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AppTopBar = memo(function AppTopBar() {
  const materialTheme = useTheme();

  const { mode, setMode } = useColorScheme();

Severity: Major
Found in frontend/src/components/layout/AppTopBar.tsx - About 4 hrs to fix

    Function useTextPage has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useTextPage(): UseTextPageReturn {
      const { sourceLanguage, fileName, queryParams, defaultQueryParams } =
        useDbQueryParams();
      const { isFallback } = useSourceFile();
    
    
    Severity: Major
    Found in frontend/src/features/textView/useTextPage.ts - About 4 hrs to fix

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

          for item in spreadsheet_fields[1]:
              worksheet.write(row, 1, str(item[1]), workbook_formats[4])
              worksheet.write(row, 2, str(item[0]), workbook_formats[2])
              row += 1
      Severity: Major
      Found in api/table_download.py and 1 other location - About 4 hrs to fix
      api/table_download.py on lines 319..322

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

      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

          for item in spreadsheet_fields[1]:
              worksheet.write(row, 2, str(item[1]), workbook_formats[4])
              worksheet.write(row, 3, str(item[0]), workbook_formats[2])
              row += 1
      Severity: Major
      Found in api/table_download.py and 1 other location - About 4 hrs to fix
      api/table_download.py on lines 59..62

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

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

      const MultiLingualSelector = () => {
        const { t } = useTranslation(["settings", "common"]);
        const router = useRouter();
        const { fileName, queryParams, uniqueSettings } = useDbQueryParams();
        const theme = useTheme();

        Function remove_duplicate_results has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        def remove_duplicate_results(results):
            results_by_segnr = {}
            for current_result in results:
                for segment_nr in current_result["segment_nr"]:
                    if not segment_nr in results_by_segnr:
        Severity: Minor
        Found in api/search/search_utils.py - 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

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

            elif lang == LANG_TIBETAN:
                last_num = ""
                for segment_key in segment_keys:
                    num = segment_key.split(":")[1].split("-")[0]
                    if num != last_num:
        Severity: Major
        Found in dataloader/folios.py and 1 other location - About 3 hrs to fix
        dataloader/folios.py on lines 8..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 71.

        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

            if lang == LANG_CHINESE:
                last_num = ""
                for segment_key in segment_keys:            
                    num = segment_key.split(":")[0].split("_")[1]
                    if num != last_num:
        Severity: Major
        Found in dataloader/folios.py and 1 other location - About 3 hrs to fix
        dataloader/folios.py on lines 15..21

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

        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

        File table_download.py has 321 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        This file contains the functions needed to create Excel
        worksheets for download
        """
        from io import BytesIO
        Severity: Minor
        Found in api/table_download.py - About 3 hrs to fix

          Function GraphPage has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function GraphPage() {
            const {
              sourceLanguage,
              fileName,
              queryParams: { score, par_length },
          Severity: Major
          Found in frontend/src/pages/db/[language]/[file]/graph.tsx - About 3 hrs to fix

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

                try:
                    par_offset_end = len(par_segment_text_joined) - (
                        len(parallel["par_segment"][-1]) - parallel["par_offset_end"]
                    )
                    par_segment_text = par_segment_text_joined[par_offset_beg:par_offset_end]
            Severity: Major
            Found in api/table_download.py and 1 other location - About 3 hrs to fix
            api/table_download.py on lines 242..248

            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

                try:
                    root_offset_end = len(root_segment_text_joined) - (
                        len(parallel["root_seg_text"][-1]) - parallel["root_offset_end"]
                    )
                    root_segment_text = root_segment_text_joined[root_offset_beg:root_offset_end]
            Severity: Major
            Found in api/table_download.py and 1 other location - About 3 hrs to fix
            api/table_download.py on lines 254..260

            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

                      <Tooltip title={displayName} PopperProps={{ disablePortal: true }}>
                        <Link
                          href={makeTextViewSegmentPath({
                            language,
                            segmentNumber,
            Severity: Major
            Found in frontend/src/features/globalSearch/SearchResultItem.tsx and 1 other location - About 3 hrs to fix
            frontend/src/features/tableView/ParallelSegment.tsx on lines 86..98

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

            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

                      <Tooltip title={displayName} PopperProps={{ disablePortal: true }}>
                        <Link
                          href={makeTextViewSegmentPath({
                            language,
                            segmentNumber: linkSegmentNumber,
            Severity: Major
            Found in frontend/src/features/tableView/ParallelSegment.tsx and 1 other location - About 3 hrs to fix
            frontend/src/features/globalSearch/SearchResultItem.tsx on lines 70..86

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

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

            export default function NumbersPage() {
              const { sourceLanguage, fileName, defaultQueryParams, queryParams } =
                useDbQueryParams();
              const { isFallback } = useSourceFile();
            
            
            Severity: Major
            Found in frontend/src/pages/db/[language]/[file]/numbers.tsx - About 3 hrs to fix

              Function useTextPage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              export function useTextPage(): UseTextPageReturn {
                const { sourceLanguage, fileName, queryParams, defaultQueryParams } =
                  useDbQueryParams();
                const { isFallback } = useSourceFile();
              
              
              Severity: Minor
              Found in frontend/src/features/textView/useTextPage.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 SearchableDbSourceTree has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function SearchableDbSourceTree(props) {
                  const {
                    parentHeight,
                    parentWidth,
                    hasHeading = true,

                Function TextViewMiddleParallels has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function TextViewMiddleParallels() {
                  const { t } = useTranslation();
                
                  const selectedSegmentMatches = useAtomValue(selectedSegmentMatchesAtom);
                
                
                Severity: Major
                Found in frontend/src/features/textView/TextViewMiddleParallels.tsx - About 3 hrs to fix

                  Function Home has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function Home() {
                    const { t } = useTranslation();
                  
                    const materialTheme = useTheme();
                  
                  
                  Severity: Major
                  Found in frontend/src/pages/index.tsx - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language