Skip to content

Commit

Permalink
Improve git grep code quality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
out-of-phaze committed Jan 23, 2025
1 parent 08f76b0 commit 5cd03cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
18 changes: 9 additions & 9 deletions code/modules/modular_computers/terminal/terminal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
account_name = "LOCAL"
else
account_name = "GUEST"
content += "<form action='byond://'><input type='hidden' name='src' value='\ref[src]'>>[account_name]:/[current_disk?.get_dir_path(current_directory, TRUE)]<input type='text' size='40' name='input' autofocus><input type='submit' value='Enter'></form>"
content += "<form action='byond://'><input type='hidden' name='src' value='\ref[src]'\>\>[account_name]:/[current_disk?.get_dir_path(current_directory, TRUE)]<input type='text' size='40' name='input' autofocus><input type='submit' value='Enter'></form>"
content += "<i>type `man` for a list of available commands.</i>"
panel.set_content("<tt>[jointext(content, "<br>")]</tt>")

Expand Down Expand Up @@ -159,7 +159,7 @@
/datum/terminal/proc/parse_directory(directory_path, create_directories = FALSE)
var/datum/file_storage/target_disk = current_disk
var/datum/computer_file/directory/root_dir = current_directory

if(!length(directory_path))
return list(target_disk, root_dir)

Expand All @@ -168,8 +168,8 @@

// Otherwise, we append the working directory path to the passed path.
var/list/directories = splittext(directory_path, "/")
// When splitting the text, there could be blank strings at either end, so remove them. If there's any in the body of the path, there was a

// When splitting the text, there could be blank strings at either end, so remove them. If there's any in the body of the path, there was a
// missed input, so leave them.
if(!length(directories[1]))
directories.Cut(1, 2)
Expand All @@ -194,7 +194,7 @@
if(!target_disk) // Invalid disk entered.
return OS_DIR_NOT_FOUND
directories.Cut(1, 2)

break // Any further use of ../ is handled by the hard drive.

// If we were only pathing to the parent of a directory or to a disk, we can return early.
Expand All @@ -208,7 +208,7 @@
var/datum/computer_file/directory/target_directory = target_disk.parse_directory(final_path, create_directories)
if(!istype(target_directory))
return OS_DIR_NOT_FOUND

return list(target_disk, target_directory)

// Returns list(/datum/file_storage, /datum/computer_file/directory, /datum/computer_file) on success. Returns error code on failure.
Expand All @@ -221,7 +221,7 @@
var/list/dirs_and_file = splittext(file_path, "/")
if(!length(dirs_and_file))
return OS_DIR_NOT_FOUND

// Join together everything but the filename into a path.
var/list/file_loc = parse_directory(jointext(dirs_and_file, "/", 1, dirs_and_file.len))
if(!islist(file_loc)) // Errored!
Expand All @@ -231,7 +231,7 @@
var/datum/computer_file/directory/target_dir = file_loc[2]
if(!istype(target_disk))
return OS_DIR_NOT_FOUND

var/filename = dirs_and_file[dirs_and_file.len]
var/datum/computer_file/target_file = target_disk.get_file(filename, target_dir)
if(!istype(target_file))
Expand Down Expand Up @@ -265,5 +265,5 @@
return "I/O error, Harddrive may be non-functional"
if(OS_NETWORK_ERROR)
return "Unable to connect to the network"

return "An unspecified error occured."
33 changes: 17 additions & 16 deletions test/check-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,35 @@ exactly() { # exactly N name search [mode] [filter]

# With the potential exception of << if you increase any of these numbers you're probably doing it wrong
# Additional exception August 2020: \b is a regex symbol as well as a BYOND macro.
exactly 1 "escapes" '\\\\(red|blue|green|black|b|i[^mc])'
exactly 8 "Del()s" '\WDel\('
exactly 3 "escapes" '\\(red|blue|green|black|b|i[^mc])'
exactly 3 "Del()s" '(?<!world/)\bDel\(' -P
exactly 2 "/atom text paths" '"/atom'
exactly 2 "/area text paths" '"/area'
exactly 2 "/datum text paths" '"/datum'
exactly 2 "/mob text paths" '"/mob'
exactly 6 "/obj text paths" '"/obj'
exactly 10 "/turf text paths" '"/turf'
exactly 1 "world<< uses" 'world<<|world[[:space:]]<<'
exactly 89 "'in world' uses" 'in world'
exactly 1 "world.log<< uses" 'world.log<<|world.log[[:space:]]<<'
exactly 18 "<< uses" '(?<!<)<<(?!<)' -P
exactly 9 ">> uses" '>>(?!>)' -P
exactly 1 "world<< uses" 'world\s*<<'
exactly 74 "'in world' uses" '\s+\bin world\b(?=\s*$|\s*//|\s*\))' -P
exactly 1 "world.log<< uses" 'world.log\s*<<'
exactly 18 "<< uses" '(?<![<\\])<<(?!<)' -P
exactly 1 "direct_output uses" '\bdirect_output\('
exactly 3 ">> uses" '(?<![>\\])>>(?!>)' -P
exactly 0 "incorrect indentations" '^( {4,})' -P
exactly 23 "text2path uses" 'text2path'
exactly 4 "update_icon() override" '/update_icon\((.*)\)' -P
exactly 0 "goto uses" 'goto '
exactly 4 "update_icon() overrides" '\/update_icon\(' -P
exactly 0 "goto uses" '\bgoto\b'
exactly 9 "atom/New uses" '^/(obj|atom|area|mob|turf).*/New\('
exactly 1 "decl/New uses" '^/decl.*/New\('
exactly 0 "tag uses" '\stag = ' -P '*.dmm'
exactly 3 "unmarked globally scoped variables" '^(/|)var/(?!global)' -P
exactly 0 "global-marked member variables" '\t(/|)var.*/global/.+' -P
exactly 0 "static-marked globally scoped variables" '^(/|)var.*/static/.+' -P
exactly 3 "tag uses" '(?<!/)\btag\s*=(?!=)' -P '*.dm *.dmm'
exactly 3 "unmarked globally scoped variables" '^/?var/(?!global)' -P
exactly 0 "global-marked member variables" '\t+/?var.*/global/' -P
exactly 0 "static-marked globally scoped variables" '^/?var.*/static/.+' -P
exactly 1 "direct usage of decls_repository.get_decl()" 'decls_repository\.get_decl\(' -P
exactly 19 "direct loc set" '(\t|;|\.)loc\s*=(?!=)' -P
exactly 19 "direct loc set" '[^ ,(/]\bloc\s*=(?!=)' -P
exactly 0 "magic number mouse opacity set" 'mouse_opacity\s*=\s*[0-2]' -P
exactly 1 "magic number density set" '\bdensity\s*=\s*[01]' -P
exactly 0 "magic number anchored set" '\banchored\s*=\s*[01]' -P
exactly 0 "magic number density set" '\bdensity\s*=\s*[01]\b' -P
exactly 0 "magic number anchored set" '\banchored\s*=\s*[01]\b' -P
exactly 0 "magic number opacity set" '\bopacity\s*=\s*[01](?!\.)' -P

# With the potential exception of << if you increase any of these numbers you're probably doing it wrong
Expand Down

0 comments on commit 5cd03cc

Please sign in to comment.