1717
1818TIMEOUT_RESPONSE_CODE = 408
1919
20+ MSG_TIMEOUT = "408: Timeout"
21+ MSG_PATH_NOT_FOUND = "Path not found"
22+ MSG_PATH_NOT_ADDED = "Path not added to repository"
23+ MSG_FRAGMENT_NOT_FOUND = "Fragment not found"
24+
2025
2126@dataclass
2227class StatusInfo :
@@ -65,8 +70,8 @@ async def process_link(link: str, session: ClientSession, config: Config) -> Lin
6570 return LinkStatus (link , str (e ))
6671 except asyncio .TimeoutError :
6772 if TIMEOUT_RESPONSE_CODE in config .catch_response_codes :
68- return LinkStatus (link , err_msg = "408: Timeout" )
69- return LinkStatus (link , warn_msg = "408: Timeout" )
73+ return LinkStatus (link , err_msg = MSG_TIMEOUT )
74+ return LinkStatus (link , warn_msg = MSG_TIMEOUT )
7075
7176 return LinkStatus (link )
7277
@@ -121,7 +126,7 @@ def check_path_links(
121126
122127 if not split_result .path :
123128 if fragment not in md_file_info .fragments :
124- ret .append (StatusInfo (md_link , "Not found header" ))
129+ ret .append (StatusInfo (md_link , MSG_FRAGMENT_NOT_FOUND ))
125130 continue
126131 else :
127132 try :
@@ -133,25 +138,25 @@ def check_path_links(
133138 abs_path = (md_abs_path .parent / split_result .path ).resolve ()
134139 rel_path = abs_path .relative_to (root_dir )
135140 except ValueError :
136- ret .append (StatusInfo (md_link , "Path is not within git repository" ))
141+ ret .append (StatusInfo (md_link , MSG_PATH_NOT_FOUND ))
137142 continue
138143
139144 if abs_path .as_posix () != abs_path .resolve ().as_posix ():
140- ret .append (StatusInfo (md_link , "Path is not within git repository" ))
145+ ret .append (StatusInfo (md_link , MSG_PATH_NOT_FOUND ))
141146 continue
142147
143148 if rel_path .as_posix () in md_data :
144149 # Markdowns in repository
145150 if fragment and fragment not in md_data [rel_path .as_posix ()].fragments :
146- ret .append (StatusInfo (md_link , "Not found fragment" ))
151+ ret .append (StatusInfo (md_link , MSG_FRAGMENT_NOT_FOUND ))
147152 continue
148153 else :
149154 # Not markdown file
150155 if not any (f .as_posix ().startswith (rel_path .as_posix ()) for f in files_in_repo ):
151156 if rel_path .exists ():
152- ret .append (StatusInfo (md_link , "File does not added to repository" ))
157+ ret .append (StatusInfo (md_link , MSG_PATH_NOT_ADDED ))
153158 else :
154- ret .append (StatusInfo (md_link , "Path does not exists in repository" ))
159+ ret .append (StatusInfo (md_link , MSG_PATH_NOT_FOUND ))
155160 continue
156161
157162 ret .append (StatusInfo (md_link ))
0 commit comments