Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 703ab7b

Browse files
committed
Fix generate_filename
1 parent b294d55 commit 703ab7b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/codacy/reporter.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ def get_git_directory():
4646
return subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).decode("utf-8").strip()
4747

4848

49-
def file_exists(rootdir, filename):
50-
for root, subFolders, files in os.walk(rootdir):
51-
if filename in files:
52-
return True
53-
else:
54-
for subFolder in subFolders:
55-
return file_exists(os.path.join(rootdir, subFolder), filename)
56-
return False
57-
58-
5949
def generate_filename(sources, filename, git_directory):
6050
def strip_prefix(line, prefix):
6151
if line.startswith(prefix):
@@ -67,9 +57,10 @@ def strip_prefix(line, prefix):
6757
git_directory = get_git_directory()
6858

6959
for source in sources:
70-
if file_exists(source, filename):
60+
if os.path.isfile(source + "/" + filename):
7161
return strip_prefix(source, git_directory).strip("/") + "/" + filename.strip("/")
7262

63+
logging.debug("File not found: " + filename)
7364
return filename
7465

7566

@@ -127,6 +118,9 @@ def percent(s):
127118
}
128119

129120
sources = [x.firstChild.nodeValue for x in report_xml.getElementsByTagName('source')]
121+
# replace windows style seperator with linux style seperator
122+
for i in range(len(sources)):
123+
sources[i] = sources[i].replace("\\", "/")
130124
classes = report_xml.getElementsByTagName('class')
131125
total_lines = 0
132126
for cls in classes:

0 commit comments

Comments
 (0)