Skip to content

Commit

Permalink
Use hostname property to create url of defect; rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
JokeWaumans committed Aug 1, 2024
1 parent e945b6e commit c5e5b97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mlx/coverity_directives/coverity_defect_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def perform_replacement(self, defects, connector, app, fromdocname):
fromdocname (str): Relative path to the document in which the error occured, without extension.
"""
env = app.builder.env
self.stream = connector.stream
self.coverity_service = connector.coverity_service
top_node = self.create_top_node(self["title"])

Expand Down Expand Up @@ -192,7 +193,7 @@ def get_filled_row(self, defect, columns, valid_columns, *args):
# CID is default and even if it is in disregard
row += self.create_cell(
str(defect["cid"]),
url=self.coverity_service.get_defect_url(self.stream, str(defect["cid"]))
url=self.coverity_service.defect_url(self.stream, str(defect["cid"]))
)
elif item_col == "LOCATION":
linenum = defect["lineNumber"]
Expand Down
14 changes: 11 additions & 3 deletions mlx/coverity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ class CoverityDefectService:
_version = "v2"

def __init__(self, hostname):
def __init__(self, transport, hostname):
self._hostname = hostname
self.base_url = f"https://{hostname.strip('/')}/api/{self.version}"
self._checkers = []
self._columns = []
self.filters = ""

@property
def hostname(self):
"""str: The hostname"""
return self._hostname

@property
def base_url(self):
"""str: The base URL of the service."""
Expand Down Expand Up @@ -458,15 +463,18 @@ def handle_component_filter(self, attribute_values):
self.filters += "<Components(%s)> " % (attribute_values)
return filter_list

def get_defect_url(self, stream, cid):
def defect_url(self, stream, cid):
"""Get URL for given defect CID
https://machine1.eng.company.com/query/defects.htm?stream=StreamA&cid=1234
Args:
stream (str): The name of the stream
cid (int): The cid of the given defect
Returns:
str: The url to the defect with given CID
"""
return f"{self.base_url}/query/defects.htm?stream={stream}&cid={cid}"
return f"https://{self.hostname.strip('/')}/query/defects.htm?stream={stream}&cid={cid}"


if __name__ == "__main__":
Expand Down

0 comments on commit c5e5b97

Please sign in to comment.