Skip to content

File handling improvements #62

@anthonyharrison

Description

@anthonyharrison

Semgrep scan identified:

1/ Files opened without corresponding close
2/ Missing encoding parameter in file open call

bids/elf_utils.py

❯❯❱ semgrep.python.lang.best-practice.open-never-closed
file object opened without corresponding close

       29┆ f = open(file, "rb")
                              
bids/library.py

❯❯❱ semgrep.python.lang.best-practice.open-never-closed
file object opened without corresponding close

       64┆ f = open(cache)

❯❱ semgrep.python.lang.best-practice.unspecified-open-encoding
      Missing 'encoding' parameter. 'open()' uses device locale encodings by default, corrupting files    
      with special characters. Specify the encoding to ensure cross-platform support when opening files in
      text mode (e.g. encoding="utf-8").                                                                  
                                                                                                          
       64┆ f = open(cache)
                             
bids/output.py

❯❯❱ semgrep.python.lang.best-practice.open-never-closed
file object opened without corresponding close

       22┆ self.file_handle = open(filename, "w", encoding="utf-8")

Affected files

  • elf_utils.py
  • library.py
  • output.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions