diff --git a/.travis.yml b/.travis.yml index 3a40513..a183310 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/lib/beautifier.py b/lib/beautifier.py index 1518b33..22eb33f 100644 --- a/lib/beautifier.py +++ b/lib/beautifier.py @@ -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] diff --git a/lib/get_answer.py b/lib/get_answer.py index aac6fb8..21c3d10 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -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: diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..f474617 --- /dev/null +++ b/sonar-project.properties @@ -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=. \ No newline at end of file