---@nodiscard Must check for errors---@param data string JSON data---@return table? parsed_data---@return string? error_messagefunction parseJSON(data) local success, result = pcall(json.decode, data) if success then return result, nil else return nil, result endend
---@nodiscard Critical: File operation result must be checked---@param filepath string File path---@param content string Content to write---@return boolean success---@return string? errorfunction writeFileSecure(filepath, content) local file, err = io.open(filepath, "w") if not file then return false, err end local success, writeErr = pcall(file.write, file, content) file:close() if not success then return false, writeErr end return true, nilend
---@nodiscard Database errors must be handled---@param query string SQL query---@return table[] results---@return string? errorfunction executeQuery(query) local results, error = database.execute(query) if error then return {}, error end return results, nilend
---@nodiscard Memory allocation may fail---@param size number Buffer size---@return buffer? bufferfunction allocateBuffer(size) if size <= 0 or size > MAX_BUFFER_SIZE then return nil end return buffer.create(size)end
-- These will trigger warnings:validateInput(userInput) -- Warning: Return value should not be discardedparseJSON(jsonString) -- Warning: Must check for errorswriteFileSecure("test.txt", "content") -- Warning: Critical: File operation result must be checked
---@nodiscard Validation result must be checked---@param email string Email address---@return boolean is_valid---@return string? error_messagefunction validateEmail(email) if not email:match("^[%w.]+@[%w.]+%.[%a]+$") then return false, "Invalid email format" end return true, nilend
---@nodiscard Resource acquisition may fail---@param config table Connection config---@return Connection? connection---@return string? errorfunction acquireConnection(config) local conn, err = Connection.new(config) if not conn then return nil, err end return conn, nilend
---@nodiscard State must be verified before proceeding---@return boolean is_readyfunction isSystemReady() return systemState == "ready" and not hasErrors()end
---@nodiscard Transaction result must be verified---@param amount number Transaction amount---@return boolean success---@return string? transaction_id---@return string? errorfunction processPayment(amount) local result = paymentGateway.charge(amount) if result.success then return true, result.id, nil else return false, nil, result.error endend