mirror of
https://github.com/chubin/cheat.sh.git
synced 2024-11-29 23:36:40 +03:00
Remove some code smells per Sonarcloud
This commit is contained in:
parent
4846328b88
commit
9fcd941087
@ -1,6 +1,15 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
addons:
|
||||
sonarcloud:
|
||||
organization: "bglopez-github"
|
||||
token:
|
||||
secure: "ne5w+ViZwv72RRlAiPhFiXpC1fy5KU9e/KaROjFGMPEOIobMLlcpKUJdVlJD1a+n9v6ZloywaCmRBu9eoxk7+2+7S8eE4xd1Ndf5AE4c4VKXhGASmzI4Vfq4ceePLcv+vF9v3S7HAwu4owlKJM2/6q1nUEugO6pSV9UC83tm2yaHuTRnREiT7HVPfvg538jOvnMC6YrSIC8EKA7dhCVEpExxXxg1tyRD19jmd1IaiREH2URI69Oy18kzbvg1qQWYkvVgUHdyt4MpkX34sWFicILEBANZm4k1Q0hxdD2hdWeiaxqrSCX8K2pBaQacssVjIZ/rQoxNQcbJJ1u4/sYiKqiJwGKtnNGj8Eh3XHIvLILb2FeRB/OqsDUUWuUmTw3ByzpqhGlGCxmuosK7ODvyDGHiSJf0XiYn02drOmKMbuai38SkW/QKb7NOJKxGt6HDfxiXvVRZiHsHVbNO8btItonYEU+4otnJ5vCs8K1C0chbISEVekx8zOtPHtwv2I6lvqLTiv+Gpo3z8uTfrURQp7zOsZVVuNiqUFumpsHltFjLHifQcMckN0QjI/AR8R4prqc/j5ZfOO28tgyp4LXSquUQm8Twygd+XeEoOP1vnz6L2vcNhf8exQ/hif/+qS0TBtAWuyAEyoPzon6sY6NxOaCicnspNIWCfwDb9TA5WJ0="
|
||||
|
||||
script:
|
||||
- sonar-scanner
|
||||
|
||||
language:
|
||||
- generic
|
||||
|
||||
|
@ -150,14 +150,10 @@ def _classify_lines(lines):
|
||||
return line_types
|
||||
|
||||
def _unindent_code(line, shift=0):
|
||||
#if line.startswith(' '):
|
||||
# return line[4:]
|
||||
|
||||
if shift == -1 and line != '':
|
||||
return ' ' + line
|
||||
|
||||
if shift > 0:
|
||||
if line.startswith(' '*shift):
|
||||
if shift > 0 and line.startswith(' '*shift):
|
||||
return line[shift:]
|
||||
|
||||
return line
|
||||
@ -245,8 +241,6 @@ def _beautify(text, filetype, add_comments=False, remove_text=False):
|
||||
lines = _cleanup_lines(lines)
|
||||
lines_classes = zip(_classify_lines(lines), lines)
|
||||
lines_classes = _wrap_lines(lines_classes, unindent_code=unindent_code)
|
||||
#for x,y in lines_classes:
|
||||
# print "%s: %s" % (x, y)
|
||||
|
||||
if remove_text:
|
||||
lines = [line[1] for line in lines_classes if line[0] == 1]
|
||||
|
@ -169,13 +169,10 @@ def get_topic_type(topic): # pylint: disable=too-many-locals,too-many-branches,t
|
||||
if '+' in topic_name:
|
||||
result = 'question'
|
||||
else:
|
||||
#if topic_type in _get_topics_dirs() and topic_name in [':list']:
|
||||
if topic_name in [':list']:
|
||||
if (topic_name in [':list']) or (topic_name in [':learn']):
|
||||
result = "internal"
|
||||
elif is_valid_learnxy(topic):
|
||||
result = 'learnxiny'
|
||||
elif topic_name in [':learn']:
|
||||
result = "internal"
|
||||
else:
|
||||
# let us activate the 'question' feature for all subsections
|
||||
result = 'question'
|
||||
@ -197,7 +194,6 @@ def get_topic_type(topic): # pylint: disable=too-many-locals,too-many-branches,t
|
||||
|
||||
TOPIC_TYPE_CACHE[topic] = result
|
||||
|
||||
#print topic, " ", result
|
||||
return result
|
||||
|
||||
#
|
||||
@ -240,10 +236,10 @@ def _get_tldr(topic):
|
||||
line = line[2:]
|
||||
if line.startswith('-'):
|
||||
line = '# '+line[2:]
|
||||
elif line == "":
|
||||
pass
|
||||
elif not line.startswith(' '):
|
||||
line = "# "+line
|
||||
else:
|
||||
pass
|
||||
|
||||
fixed_answer.append(line)
|
||||
|
||||
@ -469,7 +465,6 @@ def get_answer(topic, keyword, options="", request_options=None): # pylint: disa
|
||||
# if answer was not found in the cache
|
||||
# try to find it in one of the repositories
|
||||
if not answer:
|
||||
#topic_type = get_topic_type(topic)
|
||||
|
||||
for topic_getter_type, topic_getter in TOPIC_GETTERS:
|
||||
if topic_type == topic_getter_type:
|
||||
|
16
sonar-project.properties
Normal file
16
sonar-project.properties
Normal file
@ -0,0 +1,16 @@
|
||||
sonar.projectKey=org.bglopez-github:chtsh:master
|
||||
sonar.projectName=cheat.sh
|
||||
sonar.projectVersion=latest
|
||||
sonar.organization=bglopez-github
|
||||
|
||||
sonar.links.homepage=https://github.com/bglopez/cheat.sh
|
||||
sonar.links.ci=https://travis-ci.org/bglopez/cheat.sh
|
||||
sonar.links.scm=https://github.com/bglopez/cheat.sh
|
||||
sonar.links.issue=https://github.com/bglopez/cheat.sh/issues
|
||||
|
||||
sonar.host.url=https://sonarcloud.io
|
||||
|
||||
sonar.sourceEncoding=UTF-8
|
||||
sonar.exclusions=.git/**/*,.idea/**/*,screenshots/*,*.html,.env,.env.example
|
||||
sonar.coverage.exclusions=*.*
|
||||
sonar.sources=.
|
Loading…
Reference in New Issue
Block a user