diff --git a/src/python/evaluation/issues_statistics/README.md b/src/python/evaluation/issues_statistics/README.md index 5933edd7..0b7f83d7 100644 --- a/src/python/evaluation/issues_statistics/README.md +++ b/src/python/evaluation/issues_statistics/README.md @@ -27,3 +27,33 @@ Run the [get_raw_issues.py](get_raw_issues.py) with the arguments from command l | **‑‑to‑save‑path** | Allows to save the path to the file where the issue was found. By default, the path is not saved. | | **‑o**, **‑‑output** | Path where the dataset with raw issues will be saved. If not specified, the dataset will be saved next to the original one. | | **‑l**, **‑‑log-output** | Path where logs will be stored. If not specified, then logs will be output to stderr. | + +## Get raw issues statistics +The script takes the dataframe obtained after executing [get_raw_issues.py](get_raw_issues.py) and outputs dataframes with statistics grouped by language. + +The input dataset must have 3 obligatory columns: +- `id` +- `code` +- `lang` +- `raw_issues` + +Possible values for column `lang` are: `python3`, `kotlin`, `javascript`, `java7`, `java8`, `java9`, `java11`, `java15`. + +The output files is a new `xlsx` or `csv` files which contains the `value` column and the columns responsible for its category statistics. + +The `value` column shows the metric value (for measurable issue categories), quantity (for quantitative issue categories) or `ratio * 100` (for `CODE_STYLE` and `LINE_LEN`), where `ratio` is calculated as in the corresponding rules (`CodeStyleRule` and `LineLengthRule`). + +The table cells indicate how often value occurs in one fragment (for quantitative categories) or in all fragments (for measurable categories). + +All output datasets are arranged in folders according to language. + +### Usage +Run the [get_raw_issues_statistics.py](get_raw_issues_statistics.py) with the arguments from command line. + +**Required arguments:** +- `solutions_with_raw_issues` — path to an xlsx- or csv-file with code samples and raw issues, which were received with [get_raw_issues.py](get_raw_issues.py). + +**Optional arguments:** +| Argument | Description | +|----------|-------------| +| **‑o**, **‑‑output** | Path to the folder where datasets with statistics will be saved. If not specified, the datasets will be saved in the folder next to the original dataset. | diff --git a/src/python/evaluation/issues_statistics/get_raw_issues_statistics.py b/src/python/evaluation/issues_statistics/get_raw_issues_statistics.py new file mode 100644 index 00000000..b32fe4eb --- /dev/null +++ b/src/python/evaluation/issues_statistics/get_raw_issues_statistics.py @@ -0,0 +1,227 @@ +import argparse +import json +import logging +import sys +from collections import Counter +from json import JSONDecodeError +from pathlib import Path +from typing import Dict, List, Optional + +sys.path.append('') +sys.path.append('../../..') + +import pandas as pd +from pandarallel import pandarallel +from src.python.evaluation.common.pandas_util import get_solutions_df_by_file_path, write_df_to_file +from src.python.evaluation.common.util import ColumnName +from src.python.evaluation.issues_statistics.common.raw_issue_encoder_decoder import RawIssueDecoder +from src.python.evaluation.issues_statistics.get_raw_issues import RAW_ISSUES +from src.python.review.application_config import LanguageVersion +from src.python.review.common.file_system import Extension, get_parent_folder, get_total_code_lines_from_code +from src.python.review.common.language import Language +from src.python.review.inspectors.issue import BaseIssue, ISSUE_TYPE_TO_CLASS, IssueType, Measurable +from src.python.review.quality.rules.code_style_scoring import CodeStyleRule +from src.python.review.quality.rules.line_len_scoring import LineLengthRule +from src.python.review.reviewers.utils.code_statistics import get_code_style_lines + +ID = ColumnName.ID.value +LANG = ColumnName.LANG.value +CODE = ColumnName.CODE.value + +CODE_STYLE_LINES = f'{IssueType.CODE_STYLE.value}_lines' +CODE_STYLE_RATIO = f'{IssueType.CODE_STYLE.value}_ratio' +LINE_LEN_NUMBER = f'{IssueType.LINE_LEN.value}_number' +LINE_LEN_RATIO = f'{IssueType.LINE_LEN.value}_ratio' +TOTAL_LINES = 'total_lines' +VALUE = 'value' + +OUTPUT_DF_NAME = 'stats' +DEFAULT_OUTPUT_FOLDER_NAME = 'raw_issues_statistics' + +logger = logging.getLogger(__name__) + + +def configure_arguments(parser: argparse.ArgumentParser) -> None: + parser.add_argument( + 'solutions_with_raw_issues', + type=lambda value: Path(value).absolute(), + help=f'Local XLSX-file or CSV-file path. Your file must include column-names: ' + f'"{ID}", "{CODE}", "{LANG}", and "{RAW_ISSUES}".', + ) + + parser.add_argument( + '-o', '--output', + type=lambda value: Path(value).absolute(), + help='Path to the folder where datasets with statistics will be saved. ' + 'If not specified, the datasets will be saved in the folder next to the original one.', + ) + + parser.add_argument( + '-l', '--log-output', + type=lambda value: Path(value).absolute(), + help='Path where logs will be stored. If not specified, then logs will be output to stderr.', + ) + + +def _convert_language_code_to_language(fragment_id: str, language_code: str) -> str: + language_version = LanguageVersion.from_value(language_code) + + if language_version is None: + logger.warning(f'{fragment_id}: it was not possible to determine the language version from "{language_code}".') + return language_code + + language = Language.from_language_version(language_version) + + if language == Language.UNKNOWN: + logger.warning(f'{fragment_id}: it was not possible to determine the language from "{language_version}".') + return language_code + + return language.value + + +def _extract_stats_from_issues(row: pd.Series) -> pd.Series: + print(f'{row[ID]}: extracting stats.') + + if pd.isnull(row[CODE]): + logger.warning(f'{row[ID]}: no code.') + row[CODE] = "" + + if pd.isnull(row[LANG]): + logger.warning(f'{row[ID]}: no lang.') + row[LANG] = "" + + try: + issues: List[BaseIssue] = json.loads(row[RAW_ISSUES], cls=RawIssueDecoder) + except (JSONDecodeError, TypeError): + logger.warning(f'{row[ID]}: failed to decode issues.') + issues: List[BaseIssue] = [] + + counter = Counter([issue.type for issue in issues]) + + for issue_type, issue_class in ISSUE_TYPE_TO_CLASS.items(): + if issubclass(issue_class, Measurable): + row[issue_type.value] = [issue.measure() for issue in issues if isinstance(issue, issue_class)] + else: + row[issue_type.value] = counter[issue_type] + + row[CODE_STYLE_LINES] = get_code_style_lines(issues) + row[LINE_LEN_NUMBER] = counter[IssueType.LINE_LEN] + row[TOTAL_LINES] = get_total_code_lines_from_code(row[CODE]) + + row[LANG] = _convert_language_code_to_language(row[ID], row[LANG]) + + print(f'{row[ID]}: extraction of statistics is complete.') + + return row + + +def _convert_ratio_to_int(ratio: float): + """ + Round the ratio to 2 decimal places, multiply by 100, and take the integer part. + """ + return int((round(ratio, 2) * 100)) + + +def _group_stats_by_lang(df_with_stats: pd.DataFrame) -> Dict[str, pd.DataFrame]: + logger.info('The grouping of statistics by language has started.') + + result = {} + + df_grouped_by_lang = df_with_stats.groupby(LANG) + for lang in df_grouped_by_lang.groups: + logger.info(f'"{lang}" statistics grouping started.') + + lang_group = df_grouped_by_lang.get_group(lang) + + columns_with_stats = [] + + for issue_type, issue_class in ISSUE_TYPE_TO_CLASS.items(): + column = lang_group[issue_type.value] + if issubclass(issue_class, Measurable): + column = column.explode() + columns_with_stats.append(column.value_counts()) + + columns_with_stats.append(lang_group[TOTAL_LINES].value_counts()) + + line_len_ratio_column = lang_group.apply( + lambda row: LineLengthRule.get_ratio(row[LINE_LEN_NUMBER], row[TOTAL_LINES]), + axis=1, + ) + line_len_ratio_column = line_len_ratio_column.apply(_convert_ratio_to_int) + line_len_ratio_column.name = LINE_LEN_RATIO + columns_with_stats.append(line_len_ratio_column.value_counts()) + + code_style_ratio_column = lang_group.apply( + lambda row: CodeStyleRule.get_ratio( + row[CODE_STYLE_LINES], row[TOTAL_LINES], Language.from_value(str(lang), default=Language.UNKNOWN), + ), + axis=1, + ) + code_style_ratio_column = code_style_ratio_column.apply(_convert_ratio_to_int) + code_style_ratio_column.name = CODE_STYLE_RATIO + columns_with_stats.append(code_style_ratio_column.value_counts()) + + stats = pd.concat(columns_with_stats, axis=1).fillna(0).astype(int) + + # Put values in a separate column + stats.index.name = VALUE + stats.reset_index(inplace=True) + + result[str(lang)] = stats + logger.info(f'"{lang}" statistics grouping finished.') + + logger.info('The grouping of statistics by language has finished.') + + return result + + +def inspect_raw_issues(solutions_with_raw_issues: pd.DataFrame) -> Dict[str, pd.DataFrame]: + pandarallel.initialize() + + solutions_with_raw_issues = solutions_with_raw_issues.parallel_apply(_extract_stats_from_issues, axis=1) + + return _group_stats_by_lang(solutions_with_raw_issues) + + +def _get_output_folder(solutions_file_path: Path, output_folder: Optional[Path]): + if output_folder is not None: + return output_folder + + return get_parent_folder(solutions_file_path) / DEFAULT_OUTPUT_FOLDER_NAME + + +def _save_stats(stats_by_lang: Dict[str, pd.DataFrame], solutions_file_path: Path, output_path: Optional[Path]) -> None: + output_folder = _get_output_folder(solutions_file_path, output_path) + output_extension = Extension.get_extension_from_file(str(solutions_file_path)) + + logger.info(f'Saving statistics to a folder: {output_folder}.') + + for lang, stats in stats_by_lang.items(): + lang_folder = output_folder / lang + lang_folder.mkdir(parents=True, exist_ok=True) + write_df_to_file(stats, lang_folder / f'{OUTPUT_DF_NAME}{output_extension.value}', output_extension) + + logger.info('Saving statistics is complete.') + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + configure_arguments(parser) + args = parser.parse_args() + + if args.log_output is not None: + args.log_output.parent.mkdir(parents=True, exist_ok=True) + + logging.basicConfig( + filename=args.log_output, filemode="w", level=logging.INFO, format='%(asctime)s | %(levelname)s | %(message)s', + ) + + solutions_with_raw_issues = get_solutions_df_by_file_path(args.solutions_with_raw_issues) + + logger.info("Dataset inspection started.") + + stats_by_lang = inspect_raw_issues(solutions_with_raw_issues) + + logger.info("Dataset inspection finished.") + + _save_stats(stats_by_lang, args.solutions_with_raw_issues, args.output) diff --git a/src/python/review/application_config.py b/src/python/review/application_config.py index e2d08db1..bc59b621 100644 --- a/src/python/review/application_config.py +++ b/src/python/review/application_config.py @@ -58,3 +58,10 @@ def is_java(self) -> bool: or self == LanguageVersion.JAVA_11 or self == LanguageVersion.JAVA_15 ) + + @classmethod + def from_value(cls, value: str, default=None): + try: + return LanguageVersion(value) + except ValueError: + return default diff --git a/src/python/review/common/file_system.py b/src/python/review/common/file_system.py index bbdeeda6..952eed1a 100644 --- a/src/python/review/common/file_system.py +++ b/src/python/review/common/file_system.py @@ -233,3 +233,22 @@ def copy_directory(source: Union[str, Path], destination: Union[str, Path], dirs def copy_file(source: Union[str, Path], destination: Union[str, Path]): shutil.copy(source, destination) + + +# Before using it, check that there are no line breaks in the string +def __is_line_empty(line: str) -> bool: + return len(line.strip()) == 0 + + +def __is_comment(line: str) -> bool: + return line.strip().startswith(('#', '//')) + + +def get_total_code_lines_from_file(path: Path) -> int: + code = get_content_from_file(path, to_strip_nl=False) + return get_total_code_lines_from_code(code) + + +def get_total_code_lines_from_code(code: str) -> int: + lines = code.splitlines() + return len(list(filter(lambda line: not __is_line_empty(line) and not __is_comment(line), lines))) diff --git a/src/python/review/common/language.py b/src/python/review/common/language.py index bfe7a34c..c48944ec 100644 --- a/src/python/review/common/language.py +++ b/src/python/review/common/language.py @@ -33,6 +33,13 @@ def from_language_version(language_version: LanguageVersion) -> 'Language': def values(cls) -> List[str]: return [member.value for member in Language] + @classmethod + def from_value(cls, value: str, default=None): + try: + return Language(value) + except ValueError: + return default + EXTENSION_TO_LANGUAGE = { Extension.JAVA: Language.JAVA, diff --git a/src/python/review/quality/rules/code_style_scoring.py b/src/python/review/quality/rules/code_style_scoring.py index a1edda09..8fdabd23 100644 --- a/src/python/review/quality/rules/code_style_scoring.py +++ b/src/python/review/quality/rules/code_style_scoring.py @@ -70,7 +70,8 @@ def apply(self, n_code_style_lines, n_code_style, total_lines): self.n_code_style_lines = n_code_style_lines self.n_code_style = n_code_style - self.get_ratio(n_code_style_lines, n_code_style, total_lines) + self.update_quality(n_code_style_lines, n_code_style) + self.ratio = self.get_ratio(n_code_style_lines, total_lines, self.config.language) if self.ratio > self.config.n_code_style_bad: self.save_quality(QualityType.BAD) @@ -84,17 +85,22 @@ def apply(self, n_code_style_lines, n_code_style, total_lines): if n_code_style_lines > self.config.n_code_style_lines_bad: self.quality_type = QualityType.BAD - def get_ratio(self, n_code_style_lines, n_code_style, total_lines): + @staticmethod + def get_ratio(n_code_style_lines: int, total_lines: int, language: Language) -> float: + if language == Language.PYTHON: + return n_code_style_lines / max(1, total_lines) + else: + return n_code_style_lines / max(1, total_lines - 4) + + def update_quality(self, n_code_style_lines: int, n_code_style: int): if self.config.language == Language.PYTHON: if n_code_style == 1: self.save_quality(QualityType.MODERATE) - self.ratio = n_code_style_lines / max(1, total_lines) else: if n_code_style_lines == 1: self.save_quality(QualityType.GOOD) elif n_code_style_lines == 2: self.save_quality(QualityType.MODERATE) - self.ratio = n_code_style_lines / max(1, total_lines - 4) def __get_next_quality_type(self) -> QualityType: if self.quality_type == QualityType.BAD: diff --git a/src/python/review/quality/rules/line_len_scoring.py b/src/python/review/quality/rules/line_len_scoring.py index b188576f..50a767bf 100644 --- a/src/python/review/quality/rules/line_len_scoring.py +++ b/src/python/review/quality/rules/line_len_scoring.py @@ -31,7 +31,7 @@ def __init__(self, config: LineLengthRuleConfig): # TODO: refactor def apply(self, n_line_len, n_lines): - self.ratio = n_line_len / max(n_lines, 1) + self.ratio = self.get_ratio(n_line_len, n_lines) self.n_line_len = n_line_len self.n_lines = n_lines @@ -60,3 +60,7 @@ def merge(self, other: 'LineLengthRule') -> 'LineLengthRule': result_rule.apply(self.n_line_len + other.n_line_len, self.n_lines + other.n_lines) return result_rule + + @staticmethod + def get_ratio(n_line_len: int, n_lines: int) -> float: + return n_line_len / max(n_lines, 1) diff --git a/src/python/review/reviewers/utils/code_statistics.py b/src/python/review/reviewers/utils/code_statistics.py index 19218a7b..2d9381d9 100644 --- a/src/python/review/reviewers/utils/code_statistics.py +++ b/src/python/review/reviewers/utils/code_statistics.py @@ -3,7 +3,7 @@ from pathlib import Path from typing import Dict, List -from src.python.review.common.file_system import get_content_from_file +from src.python.review.common.file_system import get_total_code_lines_from_file from src.python.review.inspectors.issue import BaseIssue, IssueType @@ -53,19 +53,6 @@ def issue_type_to_statistics_dict(self) -> Dict[IssueType, int]: } -def __get_total_lines(path: Path) -> int: - lines = get_content_from_file(path, to_strip_nl=False).splitlines() - return len(list(filter(lambda line: not __is_empty(line) and not __is_comment(line), lines))) - - -def __is_empty(line: str) -> bool: - return len(line.strip()) == 0 - - -def __is_comment(line: str) -> bool: - return line.strip().startswith(('#', '//')) - - def get_code_style_lines(issues: List[BaseIssue]) -> int: code_style_issues = filter(lambda issue: issue.type == IssueType.CODE_STYLE, issues) line_counter = Counter([issue.line_no for issue in code_style_issues]) @@ -111,6 +98,6 @@ def gather_code_statistics(issues: List[BaseIssue], path: Path) -> CodeStatistic coupling=couplings, weighted_method_complexities=weighted_method_complexities, method_number=method_numbers, - total_lines=__get_total_lines(path), + total_lines=get_total_code_lines_from_file(path), code_style_lines=get_code_style_lines(issues), ) diff --git a/test/python/evaluation/issues_statistics/__init__.py b/test/python/evaluation/issues_statistics/__init__.py index 9a178e36..604e3d61 100644 --- a/test/python/evaluation/issues_statistics/__init__.py +++ b/test/python/evaluation/issues_statistics/__init__.py @@ -7,3 +7,9 @@ GET_RAW_ISSUES_TEST_FILES_FOLDER = GET_RAW_ISSUES_DATA_FOLDER / 'test_files' GET_RAW_ISSUES_TARGET_FILES_FOLDER = GET_RAW_ISSUES_DATA_FOLDER / 'target_files' + +GET_RAW_ISSUES_STATISTICS_DATA_FOLDER = ISSUES_STATISTICS_TEST_DATA_FOLDER / 'get_raw_issues_statistics' + +GET_RAW_ISSUES_STATISTICS_TEST_FILES_FOLDER = GET_RAW_ISSUES_STATISTICS_DATA_FOLDER / 'test_files' + +GET_RAW_ISSUES_STATISTICS_TARGET_FILES_FOLDER = GET_RAW_ISSUES_STATISTICS_DATA_FOLDER / 'target_files' diff --git a/test/python/evaluation/issues_statistics/test_get_raw_issues_statistics.py b/test/python/evaluation/issues_statistics/test_get_raw_issues_statistics.py new file mode 100644 index 00000000..24c10a67 --- /dev/null +++ b/test/python/evaluation/issues_statistics/test_get_raw_issues_statistics.py @@ -0,0 +1,112 @@ +from pathlib import Path +from test.python.common_util import equal_df +from test.python.evaluation.issues_statistics import ( + GET_RAW_ISSUES_STATISTICS_TARGET_FILES_FOLDER, + GET_RAW_ISSUES_STATISTICS_TEST_FILES_FOLDER, +) +from typing import Optional + +import pandas as pd +import pytest +from src.python.evaluation.common.pandas_util import get_solutions_df_by_file_path +from src.python.evaluation.issues_statistics.get_raw_issues_statistics import ( + _convert_language_code_to_language, + _get_output_folder, + DEFAULT_OUTPUT_FOLDER_NAME, + inspect_raw_issues, +) +from src.python.review.common.language import Language + +DF_PARENT_FOLDER_NAME = 'parent_folder' +DF_NAME = 'input_df' +DF_PATH = Path(DF_PARENT_FOLDER_NAME) / DF_NAME +DEFAULT_OUTPUT_PATH = Path(DF_PARENT_FOLDER_NAME) / DEFAULT_OUTPUT_FOLDER_NAME + +NEW_FOLDER = 'new_folder' + +GET_OUTPUT_FOLDER_PATH_TEST_DATA = [ + (DF_PATH, None, DEFAULT_OUTPUT_PATH), + (DF_PATH, Path(NEW_FOLDER), Path(NEW_FOLDER)), +] + + +@pytest.mark.parametrize( + ('solutions_file_path', 'output_folder', 'expected_output_folder'), + GET_OUTPUT_FOLDER_PATH_TEST_DATA, +) +def test_get_output_folder(solutions_file_path: Path, output_folder: Optional[Path], expected_output_folder: Path): + actual_output_folder = _get_output_folder(solutions_file_path, output_folder) + assert actual_output_folder == expected_output_folder + + +CONVERT_LANGUAGE_CODE_TO_LANGUAGE_TEST_DATA = [ + ('java7', 'JAVA'), + ('java8', 'JAVA'), + ('java9', 'JAVA'), + ('java11', 'JAVA'), + ('java15', 'JAVA'), + ('python3', 'PYTHON'), + ('kotlin', 'KOTLIN'), + ('javascript', 'JAVASCRIPT'), + ('some_weird_lang', 'some_weird_lang'), +] + + +@pytest.mark.parametrize(('language_code', 'expected_language'), CONVERT_LANGUAGE_CODE_TO_LANGUAGE_TEST_DATA) +def test_convert_language_code_to_language(language_code: str, expected_language: str): + actual_language = _convert_language_code_to_language(fragment_id='0', language_code=language_code) + assert actual_language == expected_language + + +INSPECT_SOLUTIONS_TEST_DATA = [ + ( + 'test_df_with_null.csv', + 'target_df_with_null_python.csv', + Language.PYTHON.value, + ), + ( + 'test_df_with_null.csv', + 'target_df_with_null_unknown.csv', + '', + ), + ( + 'test_df_with_empty_raw_issues.csv', + 'target_df_with_empty_raw_issues.csv', + Language.KOTLIN.value, + ), + ( + 'test_df_with_incorrect_language.csv', + 'target_df_with_incorrect_language.csv', + 'some_weird_lang', + ), + ( + 'test_df_single_lang.csv', + 'target_df_single_lang.csv', + Language.JAVA.value, + ), + ( + 'test_df_multi_lang.csv', + 'target_df_multi_lang_java.csv', + Language.JAVA.value, + ), + ( + 'test_df_multi_lang.csv', + 'target_df_multi_lang_js.csv', + Language.JS.value, + ), + ( + 'test_df_multi_lang.csv', + 'target_df_multi_lang_python.csv', + Language.PYTHON.value, + ), +] + + +@pytest.mark.parametrize(('test_file', 'target_file', 'lang'), INSPECT_SOLUTIONS_TEST_DATA) +def test_inspect_solutions(test_file: str, target_file: str, lang: str): + test_df = get_solutions_df_by_file_path(GET_RAW_ISSUES_STATISTICS_TEST_FILES_FOLDER / test_file) + stats = inspect_raw_issues(test_df) + + freq_stats = pd.read_csv(GET_RAW_ISSUES_STATISTICS_TARGET_FILES_FOLDER / target_file) + + assert equal_df(stats[lang], freq_stats) diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_java.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_java.csv new file mode 100644 index 00000000..0797881b --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_java.csv @@ -0,0 +1,14 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,2,2,3,3,3,0,0,0,0,0,0,0,3,2 +1,0,1,0,0,0,0,0,0,1,0,0,0,0,0 +3,0,0,0,0,0,0,1,1,0,0,0,0,0,0 +4,0,0,0,0,0,0,0,0,1,0,0,0,0,0 +5,0,0,0,0,0,0,0,0,1,0,0,0,0,0 +6,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +7,0,0,0,0,0,0,1,0,1,0,0,0,0,0 +11,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +14,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +19,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +33,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +34,1,0,0,0,0,0,0,0,0,0,0,0,0,0 +103,0,0,0,0,0,0,0,0,0,0,0,0,0,1 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_js.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_js.csv new file mode 100644 index 00000000..27c13bb9 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_js.csv @@ -0,0 +1,6 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,0,0,1,1,1,0,0,0,0,0,0,0,1,0 +1,0,1,0,0,0,0,0,0,0,0,0,0,0,0 +2,1,0,0,0,0,0,0,0,0,0,0,0,0,0 +9,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +40,0,0,0,0,0,0,0,0,0,0,0,0,0,1 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_python.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_python.csv new file mode 100644 index 00000000..d5749fb4 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_multi_lang_python.csv @@ -0,0 +1,12 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,1,1,2,2,2,0,0,0,0,0,0,0,2,1 +1,1,0,0,0,0,0,1,1,6,0,0,0,0,0 +2,0,1,0,0,0,0,1,0,3,0,0,0,0,0 +3,0,0,0,0,0,0,3,0,0,0,0,0,0,1 +4,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +5,0,0,0,0,0,0,2,0,0,0,0,0,0,0 +9,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +12,0,0,0,0,0,0,0,0,0,1,0,0,0,0 +14,0,0,0,0,0,0,0,0,0,0,1,0,0,0 +30,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +50,0,0,0,0,0,0,0,0,0,1,0,0,0,0 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_single_lang.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_single_lang.csv new file mode 100644 index 00000000..0797881b --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_single_lang.csv @@ -0,0 +1,14 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,2,2,3,3,3,0,0,0,0,0,0,0,3,2 +1,0,1,0,0,0,0,0,0,1,0,0,0,0,0 +3,0,0,0,0,0,0,1,1,0,0,0,0,0,0 +4,0,0,0,0,0,0,0,0,1,0,0,0,0,0 +5,0,0,0,0,0,0,0,0,1,0,0,0,0,0 +6,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +7,0,0,0,0,0,0,1,0,1,0,0,0,0,0 +11,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +14,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +19,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +33,0,0,0,0,0,0,0,0,0,0,0,1,0,0 +34,1,0,0,0,0,0,0,0,0,0,0,0,0,0 +103,0,0,0,0,0,0,0,0,0,0,0,0,0,1 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_empty_raw_issues.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_empty_raw_issues.csv new file mode 100644 index 00000000..55c2e3d8 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_empty_raw_issues.csv @@ -0,0 +1,3 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,1,1,1,1,1,0,0,0,0,0,0,0,1,1 +3,0,0,0,0,0,0,0,0,0,0,0,1,0,0 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_incorrect_language.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_incorrect_language.csv new file mode 100644 index 00000000..ebbb9c4a --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_incorrect_language.csv @@ -0,0 +1,7 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,1,0,1,1,1,0,0,0,0,0,0,0,1,1 +1,0,1,0,0,0,0,0,0,0,0,0,0,0,0 +3,0,0,0,0,0,0,0,1,0,0,0,0,0,0 +7,0,0,0,0,0,0,0,0,1,0,0,0,0,0 +11,0,0,0,0,0,0,1,0,0,0,0,0,0,0 +19,0,0,0,0,0,0,0,0,0,0,0,1,0,0 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_python.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_python.csv new file mode 100644 index 00000000..cc1ae6ea --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_python.csv @@ -0,0 +1,3 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,2,2,2,2,2,0,0,0,0,0,0,1,2,2 +1,0,0,0,0,0,0,0,0,0,0,0,1,0,0 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_unknown.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_unknown.csv new file mode 100644 index 00000000..980efd7f --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/target_files/target_df_with_null_unknown.csv @@ -0,0 +1,3 @@ +value,CODE_STYLE,BEST_PRACTICES,ERROR_PRONE,COMPLEXITY,INFO,LINE_LEN,FUNC_LEN,BOOL_EXPR_LEN,CYCLOMATIC_COMPLEXITY,MAINTAINABILITY,COHESION,total_lines,LINE_LEN_ratio,CODE_STYLE_ratio +0,1,1,1,1,1,0,0,0,0,0,0,0,1,1 +1,0,0,0,0,0,0,0,0,0,0,0,1,0,0 \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_multi_lang.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_multi_lang.csv new file mode 100644 index 00000000..129a8b51 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_multi_lang.csv @@ -0,0 +1,127 @@ +id,lang,code,raw_issues +1,java8,"import java.util.Scanner; +import java.util.Arrays; + +class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int n = scanner.nextInt(); + String[][] star = new String[n][n]; + + for (int i = 0; i < star.length; i++) { + for (int j = 0; j < star[i].length; j++) { + star[i][j] = "". ""; + if (i == (n / 2) || j == (n / 2) || i == j || j == n - i - 1) { + star[i][j] = ""* ""; + } + System.out.print(star[i][j]); + } + System.out.println(""""); + } + } +}","[{""origin_class"": ""UnusedImportsCheck"", ""type"": ""BEST_PRACTICES"", ""description"": ""Unused import - java.util.Arrays."", ""file_path"": """", ""line_no"": 2, ""column_no"": 8, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 7}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 11}, {""origin_class"": ""BooleanExpressionComplexityCheck"", ""type"": ""BOOL_EXPR_LEN"", ""description"": ""Too long boolean expression. Try to split it into smaller expressions."", ""file_path"": """", ""line_no"": 14, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 3}]" +2,java9,"import java.util.Scanner; +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int n = scanner.nextInt(); + int mas[][] = new int[n][n]; + int i; + int j; + for(i = 0; i < n; i++) { + mas[i][0] = i; + } + for (j = 0; j < n; j++) { + mas[0][j] = j; + } + for (i = 1; i < n; i++) { + for (j = 1; j < n; j++) { + mas[i][j] = mas[i][j -1] - 1; + } + } + printArray(mas, n); + } + + public static void printArray(int[][] mas, int n) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (mas[i][j] < 0) { + mas[i][j] *= -1; + } + System.out.print(mas[i][j] + "" ""); + } + System.out.println(); + } + } +}","[{""origin_class"": ""EmptyLineSeparatorCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'CLASS_DEF' should be separated from previous line."", ""file_path"": """", ""line_no"": 2, ""column_no"": 1, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 4, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 5}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 4, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 14}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 5, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 7, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 8, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""ArrayTypeStyleCheck"", ""type"": ""CODE_STYLE"", ""description"": ""Array brackets at illegal position."", ""file_path"": """", ""line_no"": 8, ""column_no"": 24, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""ArrayTypeStyleCheck"", ""type"": ""CODE_STYLE"", ""description"": ""Array brackets at illegal position."", ""file_path"": """", ""line_no"": 8, ""column_no"": 26, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 9, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 10, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 11, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""WhitespaceAfterCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' is not followed by whitespace."", ""file_path"": """", ""line_no"": 11, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 12, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 13, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 14, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 15, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 16, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 17, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 18, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 19, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""WhitespaceAroundCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'-' is not followed by whitespace."", ""file_path"": """", ""line_no"": 19, ""column_no"": 54, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 20, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 21, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 22, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def rcurly' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 23, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def modifier' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 4}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 7}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 12, expected level should be 8."", ""file_path"": """", ""line_no"": 26, ""column_no"": 13, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 20, expected level should be 12."", ""file_path"": """", ""line_no"": 27, ""column_no"": 21, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if' has incorrect indentation level 28, expected level should be 16."", ""file_path"": """", ""line_no"": 28, ""column_no"": 29, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if' child has incorrect indentation level 36, expected level should be 20."", ""file_path"": """", ""line_no"": 29, ""column_no"": 37, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if rcurly' has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 30, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 31, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 32, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 20, expected level should be 12."", ""file_path"": """", ""line_no"": 33, ""column_no"": 21, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 34, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def rcurly' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 35, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}]" +3,java11,"public class Main { + public static void main(String[] args) { + + int variable = 123456; // Change this line + + System.out.println(variable); + } +} +","[{""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 1}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 3}]" +4,python3,"class ComplexNumber: + def __init__(self, real_part, im_part): + self.real_part = real_part + self.im_part = im_part + + def __add__(self, other): + real = self.real_part + other.real_part + imaginary = self.im_part + other.im_part + return ComplexNumber(real, imaginary) + + def __mul__(self, other): + real = self.real_part * other.real_part - self.im_part * other.im_part + imaginary = self.real_part * other.im_part + other.real_part * self.im_part + return ComplexNumber(real, imaginary) + + def __eq__(self, other): + return ((self.real_part == other.real_part) and (self.im_part == other.im_part)) + + def __str__(self): + if self.im_part < 0: + sign = ""-"" + else: + sign = ""+"" + return ""{} {} {}i"".format(self.real_part, sign, abs(self.im_part)) + + def __truediv__(self, other): + div = (other.real_part ** 2 + other.im_part ** 2) + other.real_part = (other.real_part / div) + other.im_part = -(other.im_part / div) + result = self.__mul__(other) + return result + + def __sub__(self, other): + real = self.real_part - other.real_part + imaginary = self.im_part - other.im_part + return ComplexNumber(real, imaginary)","[{""origin_class"": ""C0325"", ""type"": ""CODE_STYLE"", ""description"": ""Unnecessary parens after 'return' keyword"", ""file_path"": """", ""line_no"": 17, ""column_no"": 1, ""inspector_type"": ""PYLINT""}, {""origin_class"": ""C001"", ""type"": ""BOOL_EXPR_LEN"", ""description"": ""Too long boolean expression. Try to split it into smaller expressions."", ""file_path"": """", ""line_no"": 17, ""column_no"": 16, ""inspector_type"": ""PYTHON_AST"", ""measure"": 1}, {""origin_class"": ""H601"", ""type"": ""COHESION"", ""description"": ""class has low (85.71%) cohesion"", ""file_path"": """", ""line_no"": 1, ""column_no"": 1, ""inspector_type"": ""FLAKE8"", ""measure"": 14}, {""origin_class"": ""RAD100"", ""type"": ""MAINTAINABILITY"", ""description"": ""The maintainability index is too low."", ""file_path"": """", ""line_no"": 1, ""column_no"": 1, ""inspector_type"": ""RADON"", ""measure"": 50}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 2}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 6, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 6, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 3}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 11, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 11, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 3}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 16, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 16, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 1}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 19, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 2}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 19, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 5}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 26, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 26, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 5}, {""origin_class"": ""WPS331"", ""type"": ""BEST_PRACTICES"", ""description"": ""Found variables that are only used for `return`: result"", ""file_path"": """", ""line_no"": 31, ""column_no"": 9, ""inspector_type"": ""FLAKE8""}, {""origin_class"": ""R504"", ""type"": ""BEST_PRACTICES"", ""description"": ""you shouldn`t assign value to variable if it will be use only as return value"", ""file_path"": """", ""line_no"": 31, ""column_no"": 16, ""inspector_type"": ""FLAKE8""}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 33, ""column_no"": 5, ""inspector_type"": ""FLAKE8"", ""measure"": 1}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 33, ""column_no"": 4, ""inspector_type"": ""PYTHON_AST"", ""measure"": 3}]" +5,python3,"n = int(input()) +def even(): + i = 0 + while i <= n * 2: + yield i + i += 2 +generator = even() +for _ in range(n): + print(next(generator)) + + +# Don't forget to print out the first n numbers one by one here +","[{""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 1, ""inspector_type"": ""FLAKE8"", ""measure"": 2}, {""origin_class"": ""C002"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 0, ""inspector_type"": ""PYTHON_AST"", ""measure"": 4}, {""origin_class"": ""C901"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 8, ""column_no"": 1, ""inspector_type"": ""FLAKE8"", ""measure"": 2}, {""origin_class"": ""RAD100"", ""type"": ""MAINTAINABILITY"", ""description"": ""The maintainability index is too low."", ""file_path"": """", ""line_no"": 1, ""column_no"": 1, ""inspector_type"": ""RADON"", ""measure"": 12}]" +6,javascript,"async function rockBand(str) { + return new Promise(function(resolve, reject) { + if (str == 'Linkin Park') { + resolve(""Chester, we miss you!""); + } else { + resolve(""No matter the band we miss him anyway!""); + } + }); +} +","[{""origin_class"": ""no-unused-vars"", ""type"": ""CODE_STYLE"", ""description"": ""'rockBand' is defined but never used. (no-unused-vars)"", ""file_path"": """", ""line_no"": 1, ""column_no"": 16, ""inspector_type"": ""ESLINT""}, {""origin_class"": ""no-unused-vars"", ""type"": ""CODE_STYLE"", ""description"": ""'reject' is defined but never used. (no-unused-vars)"", ""file_path"": """", ""line_no"": 2, ""column_no"": 40, ""inspector_type"": ""ESLINT""}, {""origin_class"": ""eqeqeq"", ""type"": ""BEST_PRACTICES"", ""description"": ""Expected '===' and instead saw '=='. (eqeqeq)"", ""file_path"": """", ""line_no"": 3, ""column_no"": 15, ""inspector_type"": ""ESLINT""}]" \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_single_lang.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_single_lang.csv new file mode 100644 index 00000000..b1662148 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_single_lang.csv @@ -0,0 +1,68 @@ +id,lang,code,raw_issues +1,java11,"import java.util.Scanner; +import java.util.Arrays; + +class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int n = scanner.nextInt(); + String[][] star = new String[n][n]; + + for (int i = 0; i < star.length; i++) { + for (int j = 0; j < star[i].length; j++) { + star[i][j] = "". ""; + if (i == (n / 2) || j == (n / 2) || i == j || j == n - i - 1) { + star[i][j] = ""* ""; + } + System.out.print(star[i][j]); + } + System.out.println(""""); + } + } +}","[{""origin_class"": ""UnusedImportsCheck"", ""type"": ""BEST_PRACTICES"", ""description"": ""Unused import - java.util.Arrays."", ""file_path"": """", ""line_no"": 2, ""column_no"": 8, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 7}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 11}, {""origin_class"": ""BooleanExpressionComplexityCheck"", ""type"": ""BOOL_EXPR_LEN"", ""description"": ""Too long boolean expression. Try to split it into smaller expressions."", ""file_path"": """", ""line_no"": 14, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 3}]" +2,java11,"import java.util.Scanner; +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int n = scanner.nextInt(); + int mas[][] = new int[n][n]; + int i; + int j; + for(i = 0; i < n; i++) { + mas[i][0] = i; + } + for (j = 0; j < n; j++) { + mas[0][j] = j; + } + for (i = 1; i < n; i++) { + for (j = 1; j < n; j++) { + mas[i][j] = mas[i][j -1] - 1; + } + } + printArray(mas, n); + } + + public static void printArray(int[][] mas, int n) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (mas[i][j] < 0) { + mas[i][j] *= -1; + } + System.out.print(mas[i][j] + "" ""); + } + System.out.println(); + } + } +}","[{""origin_class"": ""EmptyLineSeparatorCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'CLASS_DEF' should be separated from previous line."", ""file_path"": """", ""line_no"": 2, ""column_no"": 1, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 4, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 5}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 4, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 14}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 5, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 7, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 8, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""ArrayTypeStyleCheck"", ""type"": ""CODE_STYLE"", ""description"": ""Array brackets at illegal position."", ""file_path"": """", ""line_no"": 8, ""column_no"": 24, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""ArrayTypeStyleCheck"", ""type"": ""CODE_STYLE"", ""description"": ""Array brackets at illegal position."", ""file_path"": """", ""line_no"": 8, ""column_no"": 26, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 9, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 10, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 11, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""WhitespaceAfterCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' is not followed by whitespace."", ""file_path"": """", ""line_no"": 11, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 12, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 13, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 14, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 15, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 16, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 17, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 18, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 19, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""WhitespaceAroundCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'-' is not followed by whitespace."", ""file_path"": """", ""line_no"": 19, ""column_no"": 54, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 20, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 21, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def' child has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 22, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def rcurly' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 23, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def modifier' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 4}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 25, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 7}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 12, expected level should be 8."", ""file_path"": """", ""line_no"": 26, ""column_no"": 13, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' has incorrect indentation level 20, expected level should be 12."", ""file_path"": """", ""line_no"": 27, ""column_no"": 21, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if' has incorrect indentation level 28, expected level should be 16."", ""file_path"": """", ""line_no"": 28, ""column_no"": 29, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if' child has incorrect indentation level 36, expected level should be 20."", ""file_path"": """", ""line_no"": 29, ""column_no"": 37, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'if rcurly' has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 30, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 32, expected level should be 16."", ""file_path"": """", ""line_no"": 31, ""column_no"": 33, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 24, expected level should be 12."", ""file_path"": """", ""line_no"": 32, ""column_no"": 25, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for' child has incorrect indentation level 20, expected level should be 12."", ""file_path"": """", ""line_no"": 33, ""column_no"": 21, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'for rcurly' has incorrect indentation level 16, expected level should be 8."", ""file_path"": """", ""line_no"": 34, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""IndentationCheck"", ""type"": ""CODE_STYLE"", ""description"": ""'method def rcurly' has incorrect indentation level 8, expected level should be 4."", ""file_path"": """", ""line_no"": 35, ""column_no"": 9, ""inspector_type"": ""CHECKSTYLE""}]" +3,java11,"public class Main { + public static void main(String[] args) { + + int variable = 123456; // Change this line + + System.out.println(variable); + } +} +","[{""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 1}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 2, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 3}]" \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_empty_raw_issues.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_empty_raw_issues.csv new file mode 100644 index 00000000..37e9eca2 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_empty_raw_issues.csv @@ -0,0 +1,4 @@ +id,lang,code,raw_issues +1,kotlin,"fun main() { + println(""Hello, World!"") +}",[] \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_incorrect_language.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_incorrect_language.csv new file mode 100644 index 00000000..e98834c0 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_incorrect_language.csv @@ -0,0 +1,23 @@ +id,lang,code,raw_issues +1,some_weird_lang,"import java.util.Scanner; +import java.util.Arrays; + +class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int n = scanner.nextInt(); + String[][] star = new String[n][n]; + + for (int i = 0; i < star.length; i++) { + for (int j = 0; j < star[i].length; j++) { + star[i][j] = "". ""; + if (i == (n / 2) || j == (n / 2) || i == j || j == n - i - 1) { + star[i][j] = ""* ""; + } + System.out.print(star[i][j]); + } + System.out.println(""""); + } + } +}","[{""origin_class"": ""UnusedImportsCheck"", ""type"": ""BEST_PRACTICES"", ""description"": ""Unused import - java.util.Arrays."", ""file_path"": """", ""line_no"": 2, ""column_no"": 8, ""inspector_type"": ""CHECKSTYLE""}, {""origin_class"": ""CyclomaticComplexityCheck"", ""type"": ""CYCLOMATIC_COMPLEXITY"", ""description"": ""Too complex function. You can figure out how to simplify this code or split it into a set of small functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 7}, {""origin_class"": ""JavaNCSSCheck"", ""type"": ""FUNC_LEN"", ""description"": ""Too long function. Try to split it into smaller functions / methods. It will make your code easy to understand and less error prone."", ""file_path"": """", ""line_no"": 5, ""column_no"": 5, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 11}, {""origin_class"": ""BooleanExpressionComplexityCheck"", ""type"": ""BOOL_EXPR_LEN"", ""description"": ""Too long boolean expression. Try to split it into smaller expressions."", ""file_path"": """", ""line_no"": 14, ""column_no"": 17, ""inspector_type"": ""CHECKSTYLE"", ""measure"": 3}]" \ No newline at end of file diff --git a/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_null.csv b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_null.csv new file mode 100644 index 00000000..eab06807 --- /dev/null +++ b/test/resources/evaluation/issues_statistics/get_raw_issues_statistics/test_files/test_df_with_null.csv @@ -0,0 +1,4 @@ +id,lang,code,raw_issues +1,python3,"println(""Hello, World!"")", +2,python3,,"[]" +3,,"println(""Hello, World!"")","[]" diff --git a/whitelist.txt b/whitelist.txt index 18fd4cb7..1d4af387 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -189,3 +189,5 @@ dropna sublist dyn setdefault +isnull +filemode