archivy/archivy

View on GitHub

Showing 37 of 37 total issues

Function format_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def format_file(path: str):
    """
    Converts normal md of file at `path` to formatted archivy markdown file, with yaml front matter
    and a filename of format "{id}-{old_filename}.md"
    """
Severity: Minor
Found in archivy/data.py - 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

Avoid deeply nested control flow statements.
Open

                if which("rg"):
                    app.config["SEARCH_CONF"]["engine"] = "ripgrep"
            engine = app.config["SEARCH_CONF"]["engine"]
Severity: Major
Found in archivy/__init__.py - About 45 mins to fix

    Function show_dataobj has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def show_dataobj(dataobj_id):
        dataobj = data.get_item(dataobj_id)
        get_title_id_pairs = lambda x: (x["title"], x["id"])
        titles = list(map(get_title_id_pairs, data.get_items(structured=False)))
        js_ext = ""
    Severity: Minor
    Found in archivy/routes.py - 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

    Avoid deeply nested control flow statements.
    Open

                            if fi.param.nargs == -1:
                                # Variadic argument, in html form each argument
                                # is a separate line in a textarea.
                                # treat each line we get from text area as a separate argument.
                                for value in arg_values:
    Severity: Major
    Found in archivy/click_web/resources/cmd_exec.py - About 45 mins to fix

      Function login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def login():
          form = forms.UserForm()
          if form.validate_on_submit():
              db = get_db()
              user = db.search(
      Severity: Minor
      Found in archivy/routes.py - 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 rename_folder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def rename_folder():
          form = forms.RenameDirectoryForm()
          if form.validate_on_submit():
              try:
                  new_path = data.rename_folder(form.current_path.data, form.new_name.data)
      Severity: Minor
      Found in archivy/routes.py - 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 query_es_index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def query_es_index(query, strict=False):
          """
          Returns search results for your given query
      
          Specify strict=True if you want only exact result (in case you're using ES.
      Severity: Minor
      Found in archivy/search.py - 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 get_items has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_items(
      Severity: Minor
      Found in archivy/data.py - About 35 mins to fix

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

        def init(ctx):
            try:
                load_config()
                click.confirm(
                    "Config already found. Do you wish to reset it? "
        Severity: Minor
        Found in archivy/cli.py - 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 config_diff has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def config_diff(curr_key, curr_val, parent_dict, defaults):
            """
            This function diffs the user config with the defaults to only save what is actually different.
        
            Returns 1 if the current element or its nested elements are different and have been preserved.
        Severity: Minor
        Found in archivy/helpers.py - 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

        Avoid too many return statements within this function.
        Open

                return redirect(f"/dataobj/{dataobj_id}")
        Severity: Major
        Found in archivy/routes.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return
          Severity: Major
          Found in archivy/models.py - About 30 mins to fix

            Function insert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def insert(self):
                    """Creates a new file with the object's attributes"""
                    if self.validate():
                        for tag in self.tags:
                            add_tag_to_index(tag)
            Severity: Minor
            Found in archivy/models.py - About 25 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 serve_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def serve_image(filename):
                if filename and data.valid_image_filename(filename):
                    image_path = data.image_exists(filename)
                    if image_path:
                        return send_file(image_path)
            Severity: Minor
            Found in archivy/routes.py - About 25 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 fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fields(self) -> dict:
                    field = {}
                    param = self.param
            
                    field["param"] = param.param_type_name
            Severity: Minor
            Found in archivy/click_web/resources/input_fields.py - About 25 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 move_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def move_item(dataobj_id):
                form = forms.MoveItemForm()
                out_dir = form.path.data if form.path.data != "" else "root directory"
                if form.path.data == None:
                    flash("No path specified.")
            Severity: Minor
            Found in archivy/routes.py - About 25 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 new_bookmark has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def new_bookmark():
                default_dir = app.config.get("DEFAULT_BOOKMARKS_DIR", "root directory")
                form = forms.NewBookmarkForm(path=default_dir)
                form.path.choices = [("", "root directory")] + [
                    (pathname, pathname) for pathname in data.get_dirs()
            Severity: Minor
            Found in archivy/routes.py - About 25 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