BuddhaNexus/buddhanexus

View on GitHub

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

      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

        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

            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

                    Function FolioOption has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function FolioOption() {
                      const { t } = useTranslation("settings");
                      const { fileName, defaultParamConfig, uniqueSettings } = useDbQueryParams();
                      const { data, isLoading } = useQuery({
                        queryKey: DbApi.FolioData.makeQueryKey(fileName),

                      Function calculate_color_maps_text_view has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def calculate_color_maps_text_view(data):
                          """calculates the color maps for the text view"""
                          textleft = data["textleft"]
                          parallels_dict = dict(zip(data["parallel_ids"], data["parallels"]))
                          for entry in textleft:
                      Severity: Minor
                      Found in api/colormaps.py - 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 ScoreFilter has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function ScoreFilter() {
                        const { t } = useTranslation("settings");
                        const { defaultParamConfig, uniqueSettings } = useDbQueryParams();
                      
                        const [scoreParam, setScoreParam] = useQueryParam(

                        Function ParLengthFilter has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export default function ParLengthFilter() {
                          const { t } = useTranslation("settings");
                        
                          const { parLengthConfig, uniqueSettings } = useDbQueryParams();
                          const [parLengthParam, setParLengthParam] = useQueryParam(

                          Function LocaleSelector has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function LocaleSelector() {
                            const router = useRouter();
                            const { pathname, query, asPath, locale } = router;
                            const currentLocale = locale as SupportedLocale;
                          
                          
                          Severity: Major
                          Found in frontend/src/components/layout/LocaleSelector.tsx - About 2 hrs to fix

                            File tasks.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import os
                            from arango import (
                                DatabaseCreateError,
                                CollectionCreateError,
                                CollectionDeleteError,
                            Severity: Minor
                            Found in dataloader/tasks.py - About 2 hrs to fix

                              Function load has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def load(self, number_of_threads: int = 1) -> None:
                                      # only create collection if it does not exist
                                      db = get_database()
                                      if not check_if_collection_exists(db, self.SEARCH_COLLECTION_NAME):
                                          db.create_collection(self.SEARCH_COLLECTION_NAME)
                              Severity: Minor
                              Found in dataloader/load_segments.py - 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 Footer has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const Footer = () => {
                                const { t } = useTranslation();
                                const router = useRouter();
                                const locale = router.locale as SupportedLocale;
                              
                              
                              Severity: Major
                              Found in frontend/src/components/layout/Footer.tsx - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language