Showing 22 of 31 total issues
File edx_dl.py
has 841 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main module for the edx-dl downloader.
Function extract_urls_from_units
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def extract_urls_from_units(all_units, format_):
"""
Extract urls from units into a set of strings. Format is specified by
the user. The original purpose of this function is to export urls into
a file for external downloader.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File parsing.py
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""
Parsing and extraction functions
"""
Function remove_repeated_urls
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def remove_repeated_urls(all_units):
"""
Removes repeated urls from the units, it does not consider subtitles.
This is done to avoid repeated downloads.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def main():
"""
Main program function
"""
args = parse_args()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function download_url
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def download_url(url, filename, headers, args):
"""
Downloads the given url in filename.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parse_args
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_args():
"""
Parse the arguments/options passed to the program on the command line.
"""
parser = argparse.ArgumentParser(prog='edx-dl',
Function download
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def download(args, selections, all_units, headers):
"""
Downloads all the resources based on the selections
"""
logging.info("Output directory: " + args.output_dir)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extract_courses_from_html
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_courses_from_html(self, page, BASE_URL):
"""
Extracts courses (Course) from the html page
"""
soup = BeautifulSoup(page)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if isinstance(video, Video):
for url in video.mp4_urls:
all_urls.add('%s\n' % (format_ % {'url': url}))
else:
raise TypeError('Unknown unit video type (%s) occured '
Function _filter_sections
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _filter_sections(index, sections):
"""
Get the sections for the given index.
If the index is not valid (that is, None, a non-integer, a negative
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function download_video
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def download_video(video, args, target_dir, filename_prefix, headers):
Function extract_all_units_with_cache
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def extract_all_units_with_cache(all_urls, headers, file_formats,
Function download_unit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def download_unit(unit, args, target_dir, filename_prefix, headers):
Function extract_sections_from_html
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_sections_from_html(self, page, BASE_URL):
"""
Extract sections (Section->SubSection) from the html page
"""
def _make_url(section_soup): # FIXME: Extract from here and test
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extract_sections_from_html
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_sections_from_html(self, page, BASE_URL):
"""
Extract sections (Section->SubSection) from the html page
"""
def _make_url(section_soup): # FIXME: Extract from here and test
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function skip_or_download
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def skip_or_download(downloads, headers, args, f=download_url):
"""
downloads url into filename using download function f,
if filename exists it skips
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_subtitles_urls
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_subtitles_urls(available_subs_url, sub_template_url, headers):
"""
Request the available subs and builds the urls to download subs
"""
if available_subs_url is not None and sub_template_url is not None:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extract_sections_from_html
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extract_sections_from_html(self, page, BASE_URL):
"""
Extract sections (Section->SubSection) from the html page
"""
def _make_url(section_soup): # FIXME: Extract from here and test
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extract_subtitle_urls
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extract_subtitle_urls(self, text, BASE_URL):
re_sub_template_url = re.compile(r'data-transcript-translation-url=(?:"|")([^"&]*)(?:"|")')
re_available_subs_url = re.compile(r'data-transcript-available-translations-url=(?:"|")([^"&]*)(?:"|")')
available_subs_url = None
sub_template_url = None
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"