SonarOpenCommunity / sonar-cxx

Consider using f-strings PYL-C0209
Performance
Minor
6 months agoa year old
Formatting a regular string which could be a f-string
337        for rulename, sequences in list(self.rules.items()):
338            logging.info("%s:", rulename)
339            for i, sequence in enumerate(sequences, 1):
340                tokens = "  {}".format(i)341                for expression in sequence:
342                    tokens += ' ' + self.__keyword_upper(expression)
343                logging.info("%s", tokens)
Formatting a regular string which could be a f-string
168        for rulename, sequences in list(self.rules.items()):
169            sequences_without_opts = []
170            for i, sequence in enumerate(sequences, 1):
171                sequence.append('[[{}.{}]]'.format(rulename, i)) # add original rulename.sequence172                sequences_without_opts.extend(self.__variants(sequence))
173            self.rules[rulename] = sequences_without_opts
174
Formatting a regular string which could be a f-string
352    """
353    html = '\n' + data['description']
354    html += '\n<h2>Microsoft Documentation</h2>'
355    html += '\n<p><a href="{}" target="_blank">{}</a></p>'.format(data['href'], data['key'])356    return html
357
358
Formatting a regular string which could be a f-string
320mergerules:   create a merged file <clangtidy_merged.xml> from the input <clangtidy_new.xml> and <diagnostic_new.xml> files.
321
322check:        for each rule in <rules.xml> generate a file "/tmp/<rule_key>.ruledump", which contains the HTML code of rules description
323              check each *.ruledump file with tidy in order to validate the HTML description""" % (script_name, script_name, script_name))324    sys.exit(1)
325
326if __name__ == "__main__":
Formatting a regular string which could be a f-string
304        merged_rules.append(rule_tag)
305    with open(output, 'w') as f:
306        write_rules_xml(merged_rules, f)
307    sys.stderr.write("[INFO] Merged rules: {}\n".format(output))308
309
310def print_usage_and_exit():