id
stringlengths
7
14
test_class
dict
test_case
dict
focal_class
dict
focal_method
dict
repository
dict
4810329_146
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void function_call_type() {\n assertThat(lastExpression(\"len()\").type()).isEqualTo(InferredTypes.INT);\n }", "class_method_signature": "CallExpressionImplTest.function_call_type()", "constructor": false, "full_signature": "@Test public void function_call_type()", "identifier":...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_31
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void test_coverage_4_4_2() {\n settings.setProperty(PythonCoverageSensor.REPORT_PATHS_KEY, \"coverage.4.4.2.xml\");\n coverageSensor.execute(context);\n List<Integer> actual = IntStream.range(1, 18).mapToObj(line -> context.lineHits(FILE4_KEY, line)).collect(Collectors.toList());\n...
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_150
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void method_call_with_declared_type() {\n assertThat(lastExpression(\n \"def foo(param: str):\",\n \" x = param.capitalize()\",\n \" x\"\n ).type()).isEqualTo(DECL_STR);\n\n assertThat(lastExpression(\n \"def foo(param: A):\",\n \" x = param.capitalize()...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_27
{ "fields": [], "file": "sonar-python-plugin/src/test/java/org/sonar/plugins/python/pylint/PylintRulesDefinitionTest.java", "identifier": "PylintRulesDefinitionTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void pylint_external_repository() {\n RulesDefinition.Context context = new RulesDefinition.Context();\n PylintRulesDefinition rulesDefinition = new PylintRulesDefinition();\n rulesDefinition.define(context);\n\n assertThat(context.repositories()).hasSize(1);\n RulesDefinitio...
{ "fields": [ { "declarator": "RULES_JSON = \"org/sonar/plugins/python/pylint/rules.json\"", "modifier": "private static final", "original_string": "private static final String RULES_JSON = \"org/sonar/plugins/python/pylint/rules.json\";", "type": "String", "var_name": "RULES_JSON" ...
{ "body": "@Override\n public void define(RulesDefinition.Context context) {\n RULE_LOADER.createExternalRuleRepository(context);\n }", "class_method_signature": "PylintRulesDefinition.define(RulesDefinition.Context context)", "constructor": false, "full_signature": "@Override public void define(RulesDefin...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_107
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void not_class_symbol_in_super_class() {\n ClassSymbolImpl classASymbol = new ClassSymbolImpl(\"A\", \"mod1.A\");\n classASymbol.addSuperClass(new SymbolImpl(\"foo\", \"mod1.foo\"));\n FileInput tree = parse(\n new SymbolTableBuilder(\"my_package\", pythonFile(\"my_module.py\"...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_70
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void if_keyword() {\n assertThat(complexity(\"if x: pass\")).isEqualTo(1);\n }", "class_method_signature": "ComplexityVisitorTest.if_keyword()", "constructor": false, "full_signature": "@Test public void if_keyword()", "identifier": "if_keyword", "invocations": [ "isEqualT...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_71
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void and_keyword() {\n assertThat(complexity(\"x = a and b and c\")).isEqualTo(2);\n }", "class_method_signature": "ComplexityVisitorTest.and_keyword()", "constructor": false, "full_signature": "@Test public void and_keyword()", "identifier": "and_keyword", "invocations": [ ...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_106
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void type_hierarchy() {\n ClassSymbolImpl classASymbol = new ClassSymbolImpl(\"A\", \"mod1.A\");\n classASymbol.addSuperClass(new SymbolImpl(\"B\", \"mod2.B\"));\n Set<Symbol> mod1Symbols = Collections.singleton(classASymbol);\n ClassSymbolImpl classBSymbol = new ClassSymbolImpl...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_26
{ "fields": [], "file": "sonar-python-plugin/src/test/java/org/sonar/plugins/python/PythonTest.java", "identifier": "PythonTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void custom_file_suffixes() {\n MapSettings settings = new MapSettings();\n settings.setProperty(PythonPlugin.FILE_SUFFIXES_KEY, \"py,python\");\n\n Python language = new Python(new ConfigurationBridge(settings));\n assertThat(language.getFileSuffixes()).hasSize(2).contains(\"py...
{ "fields": [ { "declarator": "KEY = \"py\"", "modifier": "public static final", "original_string": "public static final String KEY = \"py\";", "type": "String", "var_name": "KEY" }, { "declarator": "DEFAULT_FILE_SUFFIXES = { \"py\" }", "modifier": "private static...
{ "body": "@Override\n public String[] getFileSuffixes() {\n String[] suffixes = filterEmptyStrings(configuration.getStringArray(PythonPlugin.FILE_SUFFIXES_KEY));\n return suffixes.length == 0 ? Python.DEFAULT_FILE_SUFFIXES : suffixes;\n }", "class_method_signature": "Python.getFileSuffixes()", "construct...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_151
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void method_call_with_declared_type_union_and_optional() {\n ClassSymbolImpl union = new ClassSymbolImpl(\"Union\", \"typing.Union\");\n List<DeclaredType> typeArgs = Stream.of(DECL_INT, DECL_STR).map(DeclaredType.class::cast).collect(Collectors.toList());\n assertThat(lastExpressi...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_30
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void test_coverage() {\n coverageSensor.execute(context);\n Integer[] file1Expected = {1, null, null, 0, null, 0};\n Integer[] file2Expected = {1, 3, 1, 0, 1, 1};\n\n for (int line = 1; line <= 6; line++) {\n assertThat(context.lineHits(FILE1_KEY, line)).isEqualTo(file1Expe...
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_147
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void ambiguous_callee_symbol_type() {\n FileInput fileInput = parse(\n \"class A: ...\",\n \"class A: ...\",\n \"A()\");\n\n ClassDef classDef = getLastDescendant(fileInput, t -> t.is(Tree.Kind.CLASSDEF));\n CallExpression call = getLastDescendant(fileInput, t -> t.i...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_67
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/metrics/FileMetricsTest.java", "identifier": "FileMetricsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void function_complexities() {\n assertThat(metrics(\"function-complexities.py\").functionComplexities()).containsExactly(3, 1);\n }", "class_method_signature": "FileMetricsTest.function_complexities()", "constructor": false, "full_signature": "@Test public void function_complexit...
{ "fields": [ { "declarator": "numberOfStatements", "modifier": "private", "original_string": "private int numberOfStatements;", "type": "int", "var_name": "numberOfStatements" }, { "declarator": "numberOfClasses", "modifier": "private", "original_string": "...
{ "body": "public List<Integer> functionComplexities() {\n return functionComplexities;\n }", "class_method_signature": "FileMetrics.functionComplexities()", "constructor": false, "full_signature": "public List<Integer> functionComplexities()", "identifier": "functionComplexities", "invocations": [], ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_88
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void unreachableBlocks_one() {\n ControlFlowGraph cfg = cfg(\n \"x = 10\",\n \"return\",\n \"y = 42\"\n );\n assertThat(CfgUtils.unreachableBlocks(cfg)).containsExactlyInAnyOrder(cfg.start().syntacticSuccessor());\n }", "class_method_signature": "CfgUtilsTest.unre...
{ "fields": [], "file": "python-frontend/src/main/java/org/sonar/python/cfg/CfgUtils.java", "identifier": "CfgUtils", "interfaces": "", "methods": [ { "class_method_signature": "CfgUtils.CfgUtils()", "constructor": true, "full_signature": "private CfgUtils()", "identifier": "CfgUt...
{ "body": "public static Set<CfgBlock> unreachableBlocks(ControlFlowGraph cfg) {\n Set<CfgBlock> reachableBlocks = new HashSet<>();\n Deque<CfgBlock> workList = new ArrayDeque<>();\n workList.push(cfg.start());\n while (!workList.isEmpty()) {\n CfgBlock currentBlock = workList.pop();\n if (reach...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_239
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void return_statement() {\n verifyCfg(\n \"b1(succ = [END], syntSucc = END, pred = [])\",\n \"return\");\n ControlFlowGraph cfg = verifyCfg(\n \"b1(succ = [END], syntSucc = b2, pred = [])\",\n \"return\",\n \"b2(succ = [END], pred = [])\");\n assertThat(cfg...
{ "fields": [ { "declarator": "LOG = Loggers.get(ControlFlowGraph.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(ControlFlowGraph.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "blocks", ...
{ "body": "public CfgBlock start() {\n return start;\n }", "class_method_signature": "ControlFlowGraph.start()", "constructor": false, "full_signature": "public CfgBlock start()", "identifier": "start", "invocations": [], "modifiers": "public", "parameters": "()", "return": "CfgBlock", "signatur...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_110
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void multi_level_type_hierarchy() {\n ClassSymbolImpl classASymbol = new ClassSymbolImpl(\"A\", \"mod1.A\");\n classASymbol.addSuperClass(new SymbolImpl(\"B\", \"mod2.B\"));\n Set<Symbol> mod1Symbols = Collections.singleton(classASymbol);\n\n ClassSymbolImpl classBSymbol = new C...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_242
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void simple_try_except_value_error() {\n ControlFlowGraph cfg = cfg(\n \"try:\",\n \" foo()\",\n \"except ValueError as error:\",\n \" print(error)\"\n );\n assertNoEmptyBlocksInCFG(cfg);\n CfgBlock start = cfg.start();\n assertThat(start.elements()).ext...
{ "fields": [ { "declarator": "LOG = Loggers.get(ControlFlowGraph.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(ControlFlowGraph.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "blocks", ...
{ "body": "public CfgBlock start() {\n return start;\n }", "class_method_signature": "ControlFlowGraph.start()", "constructor": false, "full_signature": "public CfgBlock start()", "identifier": "start", "invocations": [], "modifiers": "public", "parameters": "()", "return": "CfgBlock", "signatur...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_184
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void dictionary_literal() {\n setRootRule(PythonGrammar.ATOM);\n DictionaryLiteral tree = (DictionaryLiteral) parse(\"{'key': 'value'}\", treeMaker::expression);\n assertThat(tree.firstToken().value()).isEqualTo(\"{\");\n assertThat(tree.lastToken().value()).isEqualTo(\"}\");\n ...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public Expression expression(AstNode astNode) {\n if (astNode.is(PythonGrammar.ATOM) && astNode.getFirstChild().is(PythonPunctuator.LBRACKET)) {\n return listLiteral(astNode);\n }\n if (astNode.is(PythonGrammar.ATOM) && astNode.getFirstChild().is(PythonPunctuator.LPARENTHESIS)) {\n retur...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_215
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/types/TypeShedTest.java", "identifier": "TypeShedTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void package_sqlite3_connect_type_in_ambiguous_symbol() {\n Map<String, Symbol> djangoSymbols = TypeShed.symbolsForModule(\"sqlite3\").stream().collect(Collectors.toMap(Symbol::name, Function.identity(), AmbiguousSymbolImpl::create));\n Symbol requestSymbol = djangoSymbols.get(\"conne...
{ "fields": [ { "declarator": "TYPING = \"typing\"", "modifier": "private static final", "original_string": "private static final String TYPING = \"typing\";", "type": "String", "var_name": "TYPING" }, { "declarator": "TYPING_EXTENSIONS = \"typing_extensions\"", "...
{ "body": "public static Set<Symbol> symbolsForModule(String moduleName) {\n if (!TypeShed.typeShedSymbols.containsKey(moduleName)) {\n Set<Symbol> symbols = searchTypeShedForModule(moduleName);\n typeShedSymbols.put(moduleName, symbols);\n return symbols;\n }\n return TypeShed.typeShedSymbols...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_203
{ "fields": [ { "declarator": "a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"))", "modifier": "private final", "original_string": "private final InferredType a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"));", "type": "InferredType", "var_name": "a" ...
{ "body": "@Test\n public void resolveMember() {\n ClassSymbolImpl x = new ClassSymbolImpl(\"x\", \"x\");\n SymbolImpl foo = new SymbolImpl(\"foo\", null);\n x.addMembers(Arrays.asList(foo, new SymbolImpl(\"bar\", null)));\n ClassSymbolImpl y = new ClassSymbolImpl(\"y\", \"y\");\n ClassSymbolImpl z = ...
{ "fields": [ { "declarator": "types", "modifier": "private final", "original_string": "private final Set<InferredType> types;", "type": "Set<InferredType>", "var_name": "types" } ], "file": "python-frontend/src/main/java/org/sonar/python/types/UnionType.java", "identifier"...
{ "body": "@Override\n public Optional<Symbol> resolveMember(String memberName) {\n if (hasUnresolvedHierarchy()) {\n return Optional.empty();\n }\n Set<Optional<Symbol>> resolved = types.stream()\n .map(t -> t.resolveMember(memberName))\n .filter(Optional::isPresent)\n .collect(Collecto...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_192
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void test_canBeOrExtend() {\n ClassSymbolImpl x = new ClassSymbolImpl(\"x\", \"x\");\n assertThat(new DeclaredType(x).canBeOrExtend(\"x\")).isTrue();\n assertThat(new DeclaredType(x).canBeOrExtend(\"y\")).isTrue();\n }", "class_method_signature": "DeclaredTypeTest.test_canBeOrEx...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final Symbol typeClass;", "type": "Symbol", "var_name": "typeClass" }, { "declarator": "typeArgs", "modifier": "private final", "original_string": "private fi...
{ "body": "@Override\n public boolean canBeOrExtend(String typeName) {\n return true;\n }", "class_method_signature": "DeclaredType.canBeOrExtend(String typeName)", "constructor": false, "full_signature": "@Override public boolean canBeOrExtend(String typeName)", "identifier": "canBeOrExtend", "invocat...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_92
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ClassSymbolImplTest.java", "identifier": "ClassSymbolImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void isOrExtends() {\n ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"mod1.a\");\n ClassSymbolImpl b = new ClassSymbolImpl(\"b\", \"mod2.b\");\n a.addSuperClass(b);\n assertThat(a.isOrExtends(\"a\")).isFalse();\n assertThat(a.isOrExtends(\"mod1.a\")).isTrue();\n assertTh...
{ "fields": [ { "declarator": "superClasses = new ArrayList<>()", "modifier": "private final", "original_string": "private final List<Symbol> superClasses = new ArrayList<>();", "type": "List<Symbol>", "var_name": "superClasses" }, { "declarator": "allSuperClasses = nul...
{ "body": "@Override\n public boolean isOrExtends(String fullyQualifiedClassName) {\n return allSuperClasses(false).stream().anyMatch(c -> c.fullyQualifiedName() != null && Objects.equals(fullyQualifiedClassName, c.fullyQualifiedName()));\n }", "class_method_signature": "ClassSymbolImpl.isOrExtends(String full...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_223
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void test_hashCode() {\n RuntimeType aType = new RuntimeType(a);\n assertThat(aType.hashCode()).isEqualTo(new RuntimeType(a).hashCode());\n assertThat(aType.hashCode()).isNotEqualTo(new RuntimeType(b).hashCode());\n\n RuntimeType x = new RuntimeType(new ClassSymbolImpl(\"X\", nu...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final ClassSymbol typeClass;", "type": "ClassSymbol", "var_name": "typeClass" }, { "declarator": "typeClassSuperClassesFQN = null", "modifier": "private", "or...
{ "body": "@Override\n public int hashCode() {\n return Objects.hash(typeClass.name(), typeClass.fullyQualifiedName(), typeClassSuperClassesFQN(), typeClassMembersFQN());\n }", "class_method_signature": "RuntimeType.hashCode()", "constructor": false, "full_signature": "@Override public int hashCode()", "...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_235
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/plugins/python/api/PythonVisitorContextTest.java", "identifier": "PythonVisitorContextTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void initModuleFullyQualifiedName() {\n FileInput fileInput = PythonTestUtils.parse(\"def fn(): pass\");\n PythonFile pythonFile = pythonFile(\"__init__.py\");\n new PythonVisitorContext(fileInput, pythonFile, null, \"foo.bar\");\n FunctionDef functionDef = (FunctionDef) PythonT...
{ "fields": [ { "declarator": "rootTree", "modifier": "private final", "original_string": "private final FileInput rootTree;", "type": "FileInput", "var_name": "rootTree" }, { "declarator": "pythonFile", "modifier": "private final", "original_string": "priva...
{ "body": "public PythonFile pythonFile() {\n return pythonFile;\n }", "class_method_signature": "PythonVisitorContext.pythonFile()", "constructor": false, "full_signature": "public PythonFile pythonFile()", "identifier": "pythonFile", "invocations": [], "modifiers": "public", "parameters": "()", ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_84
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private final", "original_string": "private final PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" }, { "declarato...
{ "body": "@Test\n public void ignore_outer_scope() {\n FileInput fileInput = parse(\n \"def f():\",\n \" x = 42\",\n \" def inner():\",\n \" x\"\n );\n Name x = ((Name) ((ExpressionStatement) getLastDescendant(fileInput, tree -> tree.is(EXPRESSION_STMT))).expressions().get(0));\n ...
{ "fields": [ { "declarator": "programStateByBlock = new HashMap<>()", "modifier": "private final", "original_string": "private final Map<CfgBlock, ProgramStateAtBlock> programStateByBlock = new HashMap<>();", "type": "Map<CfgBlock, ProgramStateAtBlock>", "var_name": "programStateByB...
{ "body": "public Set<Expression> valuesAtLocation(Name variable) {\n Symbol symbol = variable.symbol();\n if (symbol == null) {\n return Collections.emptySet();\n }\n Set<Expression> assignedExpressions = assignedExpressionByName.get(variable);\n if (assignedExpressions != null) {\n // avoid...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_188
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/BinaryExpressionImplTest.java", "identifier": "BinaryExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void logical_expressions() {\n assertThat(lastExpression(\"42 or 43\").type()).isEqualTo(INT);\n assertThat(lastExpression(\"42 and 43\").type()).isEqualTo(INT);\n assertThat(lastExpression(\"42 or ''\").type()).isEqualTo(or(INT, STR));\n assertThat(lastExpression(\"42 or xxx\")...
{ "fields": [ { "declarator": "KINDS_BY_OPERATOR = kindsByOperator()", "modifier": "private static final", "original_string": "private static final Map<String, Kind> KINDS_BY_OPERATOR = kindsByOperator();", "type": "Map<String, Kind>", "var_name": "KINDS_BY_OPERATOR" }, { ...
{ "body": "@Override\n public InferredType type() {\n if (is(Kind.AND, Kind.OR)) {\n return InferredTypes.or(leftOperand.type(), rightOperand.type());\n }\n if (is(Kind.PLUS)) {\n InferredType leftType = leftOperand.type();\n InferredType rightType = rightOperand.type();\n if (leftType.e...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_167
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void nonlocalStatement() {\n setRootRule(PythonGrammar.NONLOCAL_STMT);\n AstNode astNode = p.parse(\"nonlocal foo\");\n StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null);\n NonlocalStatement nonlocalStatement = treeMaker.nonlocalStatement(...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public NonlocalStatement nonlocalStatement(StatementWithSeparator statementWithSeparator) {\n AstNode astNode = statementWithSeparator.statement();\n Separators separators = statementWithSeparator.separator();\n Token nonlocalKeyword = toPyToken(astNode.getFirstChild(PythonKeyword.NONLOCAL).getTok...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_10
{ "fields": [ { "declarator": "METADATA_DIR = Paths.get(\"src/main/resources/org/sonar/l10n/py/rules/python\")", "modifier": "private static final", "original_string": "private static final Path METADATA_DIR = Paths.get(\"src/main/resources/org/sonar/l10n/py/rules/python\");", "type": "Pat...
{ "body": "@Test\n public void test() {\n Iterable<Class> checks = CheckList.getChecks();\n\n for (Class cls : checks) {\n String testName = '/' + cls.getName().replace('.', '/') + \"Test.class\";\n assertThat(getClass().getResource(testName))\n .overridingErrorMessage(\"No test for \" + cls...
{ "fields": [ { "declarator": "REPOSITORY_KEY = \"python\"", "modifier": "public static final", "original_string": "public static final String REPOSITORY_KEY = \"python\";", "type": "String", "var_name": "REPOSITORY_KEY" } ], "file": "python-checks/src/main/java/org/sonar/pyt...
{ "body": "public static Iterable<Class> getChecks() {\n return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(\n AfterJumpStatementCheck.class,\n AllBranchesAreIdenticalCheck.class,\n ArgumentNumberCheck.class,\n ArgumentTypeCheck.class,\n BackslashInStringCheck.class,\n Bac...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_130
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void getFunctionSymbolFromDef() {\n FileInput fileInput = PythonTestUtils.parse(\"def foo(): pass\");\n FunctionDef functionDef = PythonTestUtils.getLastDescendant(fileInput, t -> t.is(Kind.FUNCDEF));\n\n Symbol symbolFoo = functionDef.name().symbol();\n assertThat(TreeUtils.get...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "@CheckForNull\n public static FunctionSymbol getFunctionSymbolFromDef(@Nullable FunctionDef functionDef) {\n if (functionDef == null) {\n return null;\n }\n\n Symbol functionNameSymbol = functionDef.name().symbol();\n if (functionNameSymbol == null) {\n throw new IllegalStateExceptio...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_219
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void overridden_symbol() {\n ClassSymbolImpl x = new ClassSymbolImpl(\"x\", \"x\");\n SymbolImpl fooX = new SymbolImpl(\"foo\", null);\n x.addMembers(singletonList(fooX));\n assertThat(new RuntimeType(x).resolveMember(\"foo\")).contains(fooX);\n\n ClassSymbolImpl x1 = new Cla...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final ClassSymbol typeClass;", "type": "ClassSymbol", "var_name": "typeClass" }, { "declarator": "typeClassSuperClassesFQN = null", "modifier": "private", "or...
{ "body": "@Override\n public Optional<Symbol> resolveMember(String memberName) {\n return typeClass.resolveMember(memberName);\n }", "class_method_signature": "RuntimeType.resolveMember(String memberName)", "constructor": false, "full_signature": "@Override public Optional<Symbol> resolveMember(String mem...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_47
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void test_symbol_visitor() {\n activeRules = new ActiveRulesBuilder().build();\n inputFile(FILE_2);\n inputFile(\"symbolVisitor.py\");\n sensor().execute(context);\n\n String key = \"moduleKey:file2.py\";\n assertThat(context.referencesForSymbolAt(key, 1, 10)).isNull();\n ...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_126
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void hasDescendants() {\n FileInput fileInput = parse(\"class A:\\n def foo(): pass\");\n assertThat(TreeUtils.hasDescendant(fileInput, t -> t.is(Kind.PASS_STMT))).isTrue();\n assertThat(TreeUtils.hasDescendant(fileInput, t -> (t.is(Kind.NAME) && ((Name) t).name().equals(\"foo\"))...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "public static boolean hasDescendant(Tree tree, Predicate<Tree> predicate) {\n return tree.children().stream().anyMatch(child -> predicate.test(child) || hasDescendant(child, predicate));\n }", "class_method_signature": "TreeUtils.hasDescendant(Tree tree, Predicate<Tree> predicate)", "constructor": ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_51
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void test_exception_does_not_fail_analysis() throws IOException {\n activeRules = new ActiveRulesBuilder()\n .addRule(new NewActiveRule.Builder()\n .setRuleKey(RuleKey.of(CheckList.REPOSITORY_KEY, ONE_STATEMENT_PER_LINE_RULE_KEY))\n .build())\n .addRule(new NewAct...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_2
{ "fields": [], "file": "python-checks/src/test/java/org/sonar/python/checks/CheckUtilsTest.java", "identifier": "CheckUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void comparison_equivalence() {\n assertThat(CheckUtils.areEquivalent(parse(\"foo is None\"), parse(\"foo is not None\"))).isFalse();\n assertThat(CheckUtils.areEquivalent(parse(\"x < 2\"), parse(\"x > 2\"))).isFalse();\n assertThat(CheckUtils.areEquivalent(parse(\"foo is None\"), ...
{ "fields": [], "file": "python-checks/src/main/java/org/sonar/python/checks/CheckUtils.java", "identifier": "CheckUtils", "interfaces": "", "methods": [ { "class_method_signature": "CheckUtils.CheckUtils()", "constructor": true, "full_signature": "private CheckUtils()", "identifi...
{ "body": "public static boolean areEquivalent(@Nullable Tree leftTree, @Nullable Tree rightTree) {\n if (leftTree == rightTree) {\n return true;\n }\n if (leftTree == null || rightTree == null) {\n return false;\n }\n if (leftTree.getKind() != rightTree.getKind() || leftTree.children().size(...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_171
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void argument() {\n setRootRule(PythonGrammar.ARGUMENT);\n RegularArgument argumentTree = (RegularArgument) parse(\"foo\", treeMaker::argument);\n assertThat(argumentTree.equalToken()).isNull();\n assertThat(argumentTree.keywordArgument()).isNull();\n Name name = (Name) argum...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public Argument argument(AstNode astNode) {\n AstNode compFor = astNode.getFirstChild(PythonGrammar.COMP_FOR);\n if (compFor != null) {\n Expression expression = expression(astNode.getFirstChild());\n ComprehensionExpression comprehension =\n new ComprehensionExpressionImpl(Tree.Kind...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_109
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void builtin_symbol_in_super_class() {\n ClassSymbolImpl classASymbol = new ClassSymbolImpl(\"A\", \"mod1.A\");\n classASymbol.addSuperClass(new SymbolImpl(\"BaseException\", \"BaseException\"));\n FileInput tree = parse(\n new SymbolTableBuilder(\"my_package\", pythonFile(\"m...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_220
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void cycle_between_super_types() {\n ClassSymbolImpl x = new ClassSymbolImpl(\"x\", \"x\");\n ClassSymbolImpl y = new ClassSymbolImpl(\"y\", \"y\");\n ClassSymbolImpl z = new ClassSymbolImpl(\"z\", \"z\");\n x.addSuperClass(y);\n y.addSuperClass(z);\n z.addSuperClass(x);\n...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final ClassSymbol typeClass;", "type": "ClassSymbol", "var_name": "typeClass" }, { "declarator": "typeClassSuperClassesFQN = null", "modifier": "private", "or...
{ "body": "@Override\n public boolean canHaveMember(String memberName) {\n return typeClass.canHaveMember(memberName);\n }", "class_method_signature": "RuntimeType.canHaveMember(String memberName)", "constructor": false, "full_signature": "@Override public boolean canHaveMember(String memberName)", "iden...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_91
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ClassSymbolImplTest.java", "identifier": "ClassSymbolImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void resolveMember() {\n assertThat(new ClassSymbolImpl(\"a\", null).resolveMember(\"foo\")).isEmpty();\n\n ClassSymbolImpl a = new ClassSymbolImpl(\"a\", null);\n Symbol fooA = new SymbolImpl(\"foo\", \"a.foo\");\n a.addMembers(Collections.singleton(fooA));\n assertThat(a.re...
{ "fields": [ { "declarator": "superClasses = new ArrayList<>()", "modifier": "private final", "original_string": "private final List<Symbol> superClasses = new ArrayList<>();", "type": "List<Symbol>", "var_name": "superClasses" }, { "declarator": "allSuperClasses = nul...
{ "body": "@Override\n public Optional<Symbol> resolveMember(String memberName) {\n for (Symbol symbol : allSuperClasses(false)) {\n if (symbol.kind() == Kind.CLASS) {\n ClassSymbolImpl classSymbol = (ClassSymbolImpl) symbol;\n Symbol matchingMember = classSymbol.membersByName().get(memberName)...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_29
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void absolute_path() {\n settings.setProperty(PythonCoverageSensor.REPORT_PATHS_KEY, new File(moduleBaseDir, \"coverage.xml\").getAbsolutePath());\n\n coverageSensor.execute(context);\n\n assertThat(context.lineHits(FILE1_KEY, 1)).isEqualTo(1);\n }", "class_method_signature": "P...
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_148
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void not_callable_callee_symbol_type() {\n assertThat(lastExpression(\n \"x = 42\",\n \"x()\"\n ).type()).isEqualTo(InferredTypes.anyType());\n }", "class_method_signature": "CallExpressionImplTest.not_callable_callee_symbol_type()", "constructor": false, "full_signat...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_87
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void unreachableBlocks_empty() {\n ControlFlowGraph cfg = cfg(\n \"x = 10\"\n );\n assertThat(CfgUtils.unreachableBlocks(cfg)).isEmpty();\n }", "class_method_signature": "CfgUtilsTest.unreachableBlocks_empty()", "constructor": false, "full_signature": "@Test public void...
{ "fields": [], "file": "python-frontend/src/main/java/org/sonar/python/cfg/CfgUtils.java", "identifier": "CfgUtils", "interfaces": "", "methods": [ { "class_method_signature": "CfgUtils.CfgUtils()", "constructor": true, "full_signature": "private CfgUtils()", "identifier": "CfgUt...
{ "body": "public static Set<CfgBlock> unreachableBlocks(ControlFlowGraph cfg) {\n Set<CfgBlock> reachableBlocks = new HashSet<>();\n Deque<CfgBlock> workList = new ArrayDeque<>();\n workList.push(cfg.start());\n while (!workList.isEmpty()) {\n CfgBlock currentBlock = workList.pop();\n if (reach...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_236
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/plugins/python/api/ParserTest.java", "identifier": "ParserTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void test() {\n Parser parser = new Parser();\n\n FileInput result = parser.parse(\"\");\n assertThat(result.statements()).isNull();\n\n result = parser.parse(\"foo()\");\n assertThat(result.statements().statements()).hasSize(1);\n }", "class_method_signature": "ParserTest...
{ "fields": [ { "declarator": "astParser = PythonParser.create()", "modifier": "private", "original_string": "private PythonParser astParser = PythonParser.create();", "type": "PythonParser", "var_name": "astParser" } ], "file": "python-frontend/src/main/java/org/sonar/plugin...
{ "body": "public FileInput parse(String code) {\n AstNode astNode = astParser.parse(code);\n return new PythonTreeMaker().fileInput(astNode);\n }", "class_method_signature": "Parser.parse(String code)", "constructor": false, "full_signature": "public FileInput parse(String code)", "identifier": "pars...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_68
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void file() {\n PythonVisitorContext context = TestPythonVisitorRunner.createContext(new File(\"src/test/resources/metrics/complexity.py\"));\n context.rootTree().accept(visitor);\n assertThat(visitor.getComplexity()).isEqualTo(8);\n }", "class_method_signature": "ComplexityVisi...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public int getComplexity() {\n return complexity;\n }", "class_method_signature": "ComplexityVisitor.getComplexity()", "constructor": false, "full_signature": "public int getComplexity()", "identifier": "getComplexity", "invocations": [], "modifiers": "public", "parameters": "()", "retu...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_164
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void importStatement() {\n setRootRule(PythonGrammar.IMPORT_STMT);\n AstNode astNode = p.parse(\"import foo\");\n StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null);\n ImportName importStatement = (ImportName) treeMaker.importStatement(stat...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public ImportStatement importStatement(StatementWithSeparator statementWithSeparator) {\n AstNode astNode = statementWithSeparator.statement();\n Separators separators = statementWithSeparator.separator();\n AstNode importStmt = astNode.getFirstChild();\n if (importStmt.is(PythonGrammar.IMPORT_...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_13
{ "fields": [ { "declarator": "parser = PythonParser.create()", "modifier": "private", "original_string": "private PythonParser parser = PythonParser.create();", "type": "PythonParser", "var_name": "parser" } ], "file": "python-checks/src/test/java/org/sonar/python/checks/Exp...
{ "body": "@Test\n public void unescape_string_literal() {\n assertThat(unescape(stringLiteral(\"''\"))).isEqualTo(\"\");\n assertThat(unescape(stringLiteral(\"'' ''\"))).isEqualTo(\"\");\n assertThat(unescape(stringLiteral(\"'abc' 'def'\"))).isEqualTo(\"abcdef\");\n assertThat(unescape(stringLiteral(\"'...
{ "fields": [ { "declarator": "ZERO_VALUES = new HashSet<>(Arrays.asList(\"0\", \"0.0\", \"0j\"))", "modifier": "private static final", "original_string": "private static final Set<String> ZERO_VALUES = new HashSet<>(Arrays.asList(\"0\", \"0.0\", \"0j\"));", "type": "Set<String>", "v...
{ "body": "public static String unescape(StringLiteral stringLiteral) {\n List<StringElement> elements = stringLiteral.stringElements();\n if (elements.size() == 1) {\n return unescape(elements.get(0));\n }\n return elements.stream()\n .map(Expressions::unescape)\n .collect(Collectors.joini...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_133
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void positionalParameters() {\n FileInput fileInput = PythonTestUtils.parse(\"def foo(): pass\");\n FunctionDef functionDef = PythonTestUtils.getLastDescendant(fileInput, t -> t.is(Kind.FUNCDEF));\n assertThat(TreeUtils.positionalParameters(functionDef)).isEmpty();\n\n fileInput...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "public static List<Parameter> positionalParameters(FunctionDef functionDef) {\n ParameterList parameterList = functionDef.parameters();\n if (parameterList == null) {\n return Collections.emptyList();\n }\n\n List<Parameter> result = new ArrayList<>();\n for (AnyParameter anyParameter :...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_44
{ "fields": [], "file": "sonar-python-plugin/src/test/java/org/sonar/plugins/python/flake8/Flake8RulesDefinitionTest.java", "identifier": "Flake8RulesDefinitionTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void flake8_external_repository() {\n RulesDefinition.Context context = new RulesDefinition.Context();\n Flake8RulesDefinition rulesDefinition = new Flake8RulesDefinition();\n rulesDefinition.define(context);\n\n assertThat(context.repositories()).hasSize(1);\n RulesDefinitio...
{ "fields": [ { "declarator": "RULES_JSON = \"org/sonar/plugins/python/flake8/rules.json\"", "modifier": "private static final", "original_string": "private static final String RULES_JSON = \"org/sonar/plugins/python/flake8/rules.json\";", "type": "String", "var_name": "RULES_JSON" ...
{ "body": "@Override\n public void define(RulesDefinition.Context context) {\n RULE_LOADER.createExternalRuleRepository(context);\n }", "class_method_signature": "Flake8RulesDefinition.define(RulesDefinition.Context context)", "constructor": false, "full_signature": "@Override public void define(RulesDefin...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_125
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void non_whitespace_tokens() {\n FileInput parsed = parse(\"if foo:\\n pass\");\n IfStatement ifStmt = (IfStatement) parsed.statements().statements().get(0);\n List<Token> nonWhitespaceTokens = TreeUtils.nonWhitespaceTokens(ifStmt);\n nonWhitespaceTokens.forEach(t -> assertThat...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "public static List<Token> nonWhitespaceTokens(Tree tree) {\n return TreeUtils.tokens(tree).stream()\n .filter(t -> !WHITESPACE_TOKEN_TYPES.contains(t.type()))\n .collect(Collectors.toList());\n }", "class_method_signature": "TreeUtils.nonWhitespaceTokens(Tree tree)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_52
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void test_exception_should_fail_analysis_if_configured_so() throws IOException {\n DefaultInputFile inputFile = spy(createInputFile(FILE_1));\n when(inputFile.contents()).thenThrow(FileNotFoundException.class);\n context.fileSystem().add(inputFile);\n\n activeRules = new ActiveR...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_1
{ "fields": [], "file": "python-checks/src/test/java/org/sonar/python/checks/CheckUtilsTest.java", "identifier": "CheckUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void statement_equivalence() {\n assertThat(CheckUtils.areEquivalent(parse(\"x = x + 1\"), parse(\"x = x + 1\"))).isTrue();\n assertThat(CheckUtils.areEquivalent(parse(\"x = x + 1\"), parse(\"x = x + 1\"))).isTrue();\n assertThat(CheckUtils.areEquivalent(parse(\"x = x + 1\"), parse...
{ "fields": [], "file": "python-checks/src/main/java/org/sonar/python/checks/CheckUtils.java", "identifier": "CheckUtils", "interfaces": "", "methods": [ { "class_method_signature": "CheckUtils.CheckUtils()", "constructor": true, "full_signature": "private CheckUtils()", "identifi...
{ "body": "public static boolean areEquivalent(@Nullable Tree leftTree, @Nullable Tree rightTree) {\n if (leftTree == rightTree) {\n return true;\n }\n if (leftTree == null || rightTree == null) {\n return false;\n }\n if (leftTree.getKind() != rightTree.getKind() || leftTree.children().size(...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_172
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void binary_expressions() {\n setRootRule(PythonGrammar.TEST);\n\n BinaryExpression simplePlus = binaryExpression(\"a + b\");\n assertThat(simplePlus.leftOperand()).isInstanceOf(Name.class);\n assertThat(simplePlus.operator().value()).isEqualTo(\"+\");\n assertThat(simplePlus...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "private Expression binaryExpression(AstNode astNode) {\n List<AstNode> children = astNode.getChildren();\n Expression result = expression(children.get(0));\n for (int i = 1; i < astNode.getNumberOfChildren(); i += 2) {\n AstNode operator = children.get(i);\n Expression rightOperand = exp...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_72
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void or_keyword() {\n assertThat(complexity(\"x = a or b or c\")).isEqualTo(2);\n }", "class_method_signature": "ComplexityVisitorTest.or_keyword()", "constructor": false, "full_signature": "@Test public void or_keyword()", "identifier": "or_keyword", "invocations": [ "isE...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_105
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void aliased_imported_symbols() {\n SymbolImpl xSymbol = new SymbolImpl(\"x\", \"mod.x\");\n List<Symbol> modSymbols = Collections.singletonList(xSymbol);\n Map<String, Set<Symbol>> globalSymbols = Collections.singletonMap(\"mod\", new HashSet<>(modSymbols));\n FileInput tree = ...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_25
{ "fields": [], "file": "sonar-python-plugin/src/test/java/org/sonar/plugins/python/PythonTest.java", "identifier": "PythonTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void test() {\n Python language = new Python(new ConfigurationBridge(new MapSettings()));\n assertThat(language.getKey()).isEqualTo(\"py\");\n assertThat(language.getName()).isEqualTo(\"Python\");\n assertThat(language.getFileSuffixes()).hasSize(1).contains(\"py\");\n }", "cl...
{ "fields": [ { "declarator": "KEY = \"py\"", "modifier": "public static final", "original_string": "public static final String KEY = \"py\";", "type": "String", "var_name": "KEY" }, { "declarator": "DEFAULT_FILE_SUFFIXES = { \"py\" }", "modifier": "private static...
{ "body": "@Override\n public String[] getFileSuffixes() {\n String[] suffixes = filterEmptyStrings(configuration.getStringArray(PythonPlugin.FILE_SUFFIXES_KEY));\n return suffixes.length == 0 ? Python.DEFAULT_FILE_SUFFIXES : suffixes;\n }", "class_method_signature": "Python.getFileSuffixes()", "construct...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_152
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void inner_class_constructor_declared_type() {\n InferredType type = lastExpression(\n \"class A:\",\n \" class B: ...\",\n \"def foo(param: A):\",\n \" x = param.B()\",\n \" x\"\n ).type();\n assertThat(type).isInstanceOf(DeclaredType.class);\n asser...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_33
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void test_unique_report() {\n settings.setProperty(PythonCoverageSensor.REPORT_PATHS_KEY, \"*coverage.4.4.2*.xml\");\n settings.setProperty(PythonCoverageSensor.REPORT_PATH_KEY, \"*coverage.4.4.2*.xml\");\n coverageSensor.execute(context);\n List<Integer> actual = IntStream.rang...
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_144
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/UnaryExpressionImplTest.java", "identifier": "UnaryExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void type() {\n assertThat(lastExpression(\"not 42\").type()).isEqualTo(BOOL);\n assertThat(lastExpression(\"-42\").type()).isEqualTo(InferredTypes.anyType());\n assertThat(lastExpression(\"+42\").type()).isEqualTo(InferredTypes.anyType());\n assertThat(lastExpression(\"~42\").t...
{ "fields": [ { "declarator": "KINDS_BY_OPERATOR = kindsByOperator()", "modifier": "private static final", "original_string": "private static final Map<String, Kind> KINDS_BY_OPERATOR = kindsByOperator();", "type": "Map<String, Kind>", "var_name": "KINDS_BY_OPERATOR" }, { ...
{ "body": "@Override\n public InferredType type() {\n if (is(Kind.NOT)) {\n return InferredTypes.BOOL;\n }\n return InferredTypes.anyType();\n }", "class_method_signature": "UnaryExpressionImpl.type()", "constructor": false, "full_signature": "@Override public InferredType type()", "identifier...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_64
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/metrics/FileMetricsTest.java", "identifier": "FileMetricsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void classes() {\n assertThat(metrics(\"classes.py\").numberOfClasses()).isEqualTo(1);\n }", "class_method_signature": "FileMetricsTest.classes()", "constructor": false, "full_signature": "@Test public void classes()", "identifier": "classes", "invocations": [ "isEqualTo",...
{ "fields": [ { "declarator": "numberOfStatements", "modifier": "private", "original_string": "private int numberOfStatements;", "type": "int", "var_name": "numberOfStatements" }, { "declarator": "numberOfClasses", "modifier": "private", "original_string": "...
{ "body": "public int numberOfClasses() {\n return numberOfClasses;\n }", "class_method_signature": "FileMetrics.numberOfClasses()", "constructor": false, "full_signature": "public int numberOfClasses()", "identifier": "numberOfClasses", "invocations": [], "modifiers": "public", "parameters": "()", ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_113
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void imports_wont_trigger_typeshed_lookup() {\n // Imports from the file with the same name and with null name won't trigger TypeShed.symbolWithFQN\n FileInput tree = parse(\n new SymbolTableBuilder(\"\", pythonFile(\"os.py\"), empty()),\n \"from os import *\",\n \"from...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable empty() {\n return new ProjectLevelSymbolTable(Collections.emptyMap());\n }", "class_method_signature": "ProjectLevelSymbolTable.empty()", "constructor": false, "full_signature": "public static ProjectLevelSymbolTable empty()", "identifier": "empty", "inv...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_241
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void return_outside_function() {\n assertThat(ControlFlowGraph.build(PythonTestUtils.parse(\"return\"), file)).isNull();\n assertThat(cfg(\n \"class Foo:\",\n \" return\"\n )).isNull();\n }", "class_method_signature": "ControlFlowGraphTest.return_outside_function()"...
{ "fields": [ { "declarator": "LOG = Loggers.get(ControlFlowGraph.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(ControlFlowGraph.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "blocks", ...
{ "body": "@CheckForNull\n private static ControlFlowGraph build(@Nullable StatementList statementList, PythonFile file) {\n if (!treesWithCfgErrors.contains(statementList)) {\n try {\n return new ControlFlowGraphBuilder(statementList).getCfg();\n } catch (Exception e) {\n treesWithCfgErro...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_168
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void expression_statement() {\n setRootRule(PythonGrammar.EXPRESSION_STMT);\n AstNode astNode = p.parse(\"'foo'\");\n StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null);\n ExpressionStatement expressionStatement = treeMaker.expressionStatem...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public ExpressionStatement expressionStatement(StatementWithSeparator statementWithSeparator) {\n AstNode astNode = statementWithSeparator.statement();\n Separators separators = statementWithSeparator.separator();\n List<Expression> expressions = astNode.getFirstChild(PythonGrammar.TESTLIST_STAR_E...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_187
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/BinaryExpressionImplTest.java", "identifier": "BinaryExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void type() {\n assertThat(lastExpression(\"42 + 43\").type()).isEqualTo(INT);\n assertThat(lastExpression(\"'foo' + 'bar'\").type()).isEqualTo(STR);\n assertThat(lastExpression(\"True + False\").type()).isEqualTo(InferredTypes.anyType());\n assertThat(lastExpression(\"42 + ''\"...
{ "fields": [ { "declarator": "KINDS_BY_OPERATOR = kindsByOperator()", "modifier": "private static final", "original_string": "private static final Map<String, Kind> KINDS_BY_OPERATOR = kindsByOperator();", "type": "Map<String, Kind>", "var_name": "KINDS_BY_OPERATOR" }, { ...
{ "body": "@Override\n public InferredType type() {\n if (is(Kind.AND, Kind.OR)) {\n return InferredTypes.or(leftOperand.type(), rightOperand.type());\n }\n if (is(Kind.PLUS)) {\n InferredType leftType = leftOperand.type();\n InferredType rightType = rightOperand.type();\n if (leftType.e...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_48
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void test_issues() {\n activeRules = new ActiveRulesBuilder()\n .addRule(new NewActiveRule.Builder()\n .setRuleKey(RuleKey.of(CheckList.REPOSITORY_KEY, ONE_STATEMENT_PER_LINE_RULE_KEY))\n .build())\n .addRule(new NewActiveRule.Builder()\n .setRuleKey(RuleKe...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_216
{ "fields": [ { "declarator": "a = new SymbolImpl(\"a\", \"foo.a\")", "modifier": "private final", "original_string": "private final SymbolImpl a = new SymbolImpl(\"a\", \"foo.a\");", "type": "SymbolImpl", "var_name": "a" }, { "declarator": "b = new SymbolImpl(\"b\", \"...
{ "body": "@Test\n public void test_equals() {\n TypeInferenceProgramState typeInferenceProgramState = new TypeInferenceProgramState();\n assertThat(typeInferenceProgramState)\n .isEqualTo(typeInferenceProgramState)\n .isEqualTo(new TypeInferenceProgramState())\n .isNotEqualTo(otherProgramState)...
{ "fields": [ { "declarator": "inferredTypesBySymbol", "modifier": "private final", "original_string": "private final Map<Symbol, Set<InferredType>> inferredTypesBySymbol;", "type": "Map<Symbol, Set<InferredType>>", "var_name": "inferredTypesBySymbol" } ], "file": "python-fro...
{ "body": "void setTypes(Symbol symbol, Set<InferredType> types) {\n inferredTypesBySymbol.put(symbol, types);\n }", "class_method_signature": "TypeInferenceProgramState.setTypes(Symbol symbol, Set<InferredType> types)", "constructor": false, "full_signature": " void setTypes(Symbol symbol, Set<InferredType...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_200
{ "fields": [ { "declarator": "a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"))", "modifier": "private final", "original_string": "private final InferredType a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"));", "type": "InferredType", "var_name": "a" ...
{ "body": "@Test\n public void construction() {\n assertThat(or(anyType(), anyType())).isEqualTo(anyType());\n assertThat(or(anyType(), a)).isEqualTo(anyType());\n assertThat(or(a, anyType())).isEqualTo(anyType());\n assertThat(or(a, a)).isEqualTo(a);\n assertThat(or(a, b)).isNotEqualTo(anyType());\n ...
{ "fields": [ { "declarator": "types", "modifier": "private final", "original_string": "private final Set<InferredType> types;", "type": "Set<InferredType>", "var_name": "types" } ], "file": "python-frontend/src/main/java/org/sonar/python/types/UnionType.java", "identifier"...
{ "body": "public static InferredType or(InferredType type1, InferredType type2) {\n if (type1.equals(anyType()) || type2.equals(anyType())) {\n return anyType();\n }\n if (type1.equals(type2)) {\n return type1;\n }\n Set<InferredType> types = new HashSet<>();\n addTypes(type1, types);\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_129
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IllegalStateException.class)\n public void getClassSymbolFromDef_illegalSymbol() {\n FileInput fileInput = PythonTestUtils.parseWithoutSymbols(\"class A:\\n def foo(): pass\");\n ClassDef classDef = PythonTestUtils.getLastDescendant(fileInput, t -> t.is(Kind.CLASSDEF));\n\n Tree...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "@CheckForNull\n public static ClassSymbol getClassSymbolFromDef(@Nullable ClassDef classDef) {\n if (classDef == null) {\n return null;\n }\n\n Symbol classNameSymbol = classDef.name().symbol();\n if (classNameSymbol == null) {\n throw new IllegalStateException(\"A ClassDef should al...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_191
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void test_canOnlyBe() {\n assertThat(new DeclaredType(a).canOnlyBe(\"a\")).isFalse();\n assertThat(new DeclaredType(b).canOnlyBe(\"a\")).isFalse();\n }", "class_method_signature": "DeclaredTypeTest.test_canOnlyBe()", "constructor": false, "full_signature": "@Test public void te...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final Symbol typeClass;", "type": "Symbol", "var_name": "typeClass" }, { "declarator": "typeArgs", "modifier": "private final", "original_string": "private fi...
{ "body": "@Override\n public boolean canOnlyBe(String typeName) {\n return false;\n }", "class_method_signature": "DeclaredType.canOnlyBe(String typeName)", "constructor": false, "full_signature": "@Override public boolean canOnlyBe(String typeName)", "identifier": "canOnlyBe", "invocations": [], "m...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_190
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void isIdentityComparableWith() {\n DeclaredType aType = new DeclaredType(a);\n DeclaredType bType = new DeclaredType(b);\n DeclaredType cType = new DeclaredType(c);\n\n assertThat(aType.isIdentityComparableWith(bType)).isTrue();\n assertThat(aType.isIdentityComparableWith(aT...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final Symbol typeClass;", "type": "Symbol", "var_name": "typeClass" }, { "declarator": "typeArgs", "modifier": "private final", "original_string": "private fi...
{ "body": "@Override\n public boolean isIdentityComparableWith(InferredType other) {\n return true;\n }", "class_method_signature": "DeclaredType.isIdentityComparableWith(InferredType other)", "constructor": false, "full_signature": "@Override public boolean isIdentityComparableWith(InferredType other)", ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_128
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void getClassSymbolFromDef() {\n FileInput fileInput = PythonTestUtils.parse(\"class A:\\n def foo(): pass\");\n ClassDef classDef = PythonTestUtils.getLastDescendant(fileInput, t -> t.is(Kind.CLASSDEF));\n\n Symbol symbolA = classDef.name().symbol();\n assertThat(TreeUtils.get...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "@CheckForNull\n public static ClassSymbol getClassSymbolFromDef(@Nullable ClassDef classDef) {\n if (classDef == null) {\n return null;\n }\n\n Symbol classNameSymbol = classDef.name().symbol();\n if (classNameSymbol == null) {\n throw new IllegalStateException(\"A ClassDef should al...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_201
{ "fields": [ { "declarator": "a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"))", "modifier": "private final", "original_string": "private final InferredType a = InferredTypes.runtimeType(new ClassSymbolImpl(\"a\", \"a\"));", "type": "InferredType", "var_name": "a" ...
{ "body": "@Test\n public void isIdentityComparableWith() {\n assertThat(or(a, b).isIdentityComparableWith(anyType())).isTrue();\n assertThat(or(a, b).isIdentityComparableWith(a)).isTrue();\n assertThat(or(a, b).isIdentityComparableWith(b)).isTrue();\n assertThat(or(a, b).isIdentityComparableWith(c)).isF...
{ "fields": [ { "declarator": "types", "modifier": "private final", "original_string": "private final Set<InferredType> types;", "type": "Set<InferredType>", "var_name": "types" } ], "file": "python-frontend/src/main/java/org/sonar/python/types/UnionType.java", "identifier"...
{ "body": "@Override\n public boolean isIdentityComparableWith(InferredType other) {\n return types.stream().anyMatch(t -> t.isIdentityComparableWith(other));\n }", "class_method_signature": "UnionType.isIdentityComparableWith(InferredType other)", "constructor": false, "full_signature": "@Override public ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_49
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void cross_files_secondary_locations() {\n activeRules = new ActiveRulesBuilder()\n .addRule(new NewActiveRule.Builder()\n .setRuleKey(RuleKey.of(CheckList.REPOSITORY_KEY, \"S930\"))\n .build())\n .build();\n\n InputFile mainFile = inputFile(\"main.py\");\n ...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_217
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/types/InferredTypesTest.java", "identifier": "InferredTypesTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void test_isDeclaredTypeWithTypeClass() {\n assertThat(isDeclaredTypeWithTypeClass(DECL_INT, \"int\")).isTrue();\n assertThat(isDeclaredTypeWithTypeClass(INT, \"int\")).isFalse();\n assertThat(isDeclaredTypeWithTypeClass(lastExpression(\n \"from typing import List\",\n \"...
{ "fields": [ { "declarator": "ALIASED_ANNOTATIONS = new HashMap<>()", "modifier": "private static final", "original_string": "private static final Map<String, String> ALIASED_ANNOTATIONS = new HashMap<>();", "type": "Map<String, String>", "var_name": "ALIASED_ANNOTATIONS" }, ...
{ "body": "public static boolean isDeclaredTypeWithTypeClass(InferredType type, String typeName) {\n if (type instanceof DeclaredType) {\n Symbol typeClass = ((DeclaredType) type).getTypeClass();\n return typeName.equals(typeClass.fullyQualifiedName());\n }\n return false;\n }", "class_method_si...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_169
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void compound_assignement_statement() {\n setRootRule(PythonGrammar.EXPRESSION_STMT);\n AstNode astNode = p.parse(\"x += y\");\n StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null);\n CompoundAssignmentStatement pyCompoundAssignmentStatement...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public CompoundAssignmentStatement compoundAssignment(StatementWithSeparator statementWithSeparator) {\n AstNode astNode = statementWithSeparator.statement();\n Separators separators = statementWithSeparator.separator();\n AstNode augAssignNodes = astNode.getFirstChild(PythonGrammar.AUGASSIGN);\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_186
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void variables() {\n setRootRule(PythonGrammar.EXPR);\n Name name = (Name) parse(\"foo\", treeMaker::expression);\n assertThat(name.isVariable()).isTrue();\n\n QualifiedExpression qualifiedExpressionTree = (QualifiedExpression) parse(\"a.b\", treeMaker::expression);\n assertT...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "private static Name name(AstNode astNode) {\n return new NameImpl(toPyToken(astNode.getFirstChild(GenericTokenType.IDENTIFIER).getToken()), astNode.getParent().is(PythonGrammar.ATOM));\n }", "class_method_signature": "PythonTreeMaker.name(AstNode astNode)", "constructor": false, "full_signature":...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_240
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private", "original_string": "private PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" } ], "file": "python-frontend/src...
{ "body": "@Test\n public void while_statement() {\n ControlFlowGraph cfg = verifyCfg(\n \"before(succ = [cond_block], elem = 1)\",\n \"while cond_block(succ = [while_body, END], elem = 1):\",\n \" while_body(succ = [cond_block], elem = 1)\"\n );\n CfgBranchingBlock condBlock = (CfgBranching...
{ "fields": [ { "declarator": "LOG = Loggers.get(ControlFlowGraph.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(ControlFlowGraph.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "blocks", ...
{ "body": "public CfgBlock start() {\n return start;\n }", "class_method_signature": "ControlFlowGraph.start()", "constructor": false, "full_signature": "public CfgBlock start()", "identifier": "start", "invocations": [], "modifiers": "public", "parameters": "()", "return": "CfgBlock", "signatur...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_112
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void imported_class_hasSuperClassWithoutSymbol() {\n Set<Symbol> modSymbols = parse(\n new SymbolTableBuilder(\"\", pythonFile(\"mod\")),\n \"def foo(): ...\",\n \"class A(foo()): ...\"\n ).globalVariables();\n Map<String, Set<Symbol>> globalSymbols = Collections.sin...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_65
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/metrics/FileMetricsTest.java", "identifier": "FileMetricsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void complexity() {\n assertThat(metrics(\"complexity.py\").complexity()).isEqualTo(8);\n }", "class_method_signature": "FileMetricsTest.complexity()", "constructor": false, "full_signature": "@Test public void complexity()", "identifier": "complexity", "invocations": [ "i...
{ "fields": [ { "declarator": "numberOfStatements", "modifier": "private", "original_string": "private int numberOfStatements;", "type": "int", "var_name": "numberOfStatements" }, { "declarator": "numberOfClasses", "modifier": "private", "original_string": "...
{ "body": "public int complexity() {\n return complexityVisitor.getComplexity();\n }", "class_method_signature": "FileMetrics.complexity()", "constructor": false, "full_signature": "public int complexity()", "identifier": "complexity", "invocations": [ "getComplexity" ], "modifiers": "public", ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_145
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void constructor_type() {\n FileInput fileInput = parse(\n \"class A: ...\",\n \"A()\");\n\n ClassDef classDef = getLastDescendant(fileInput, t -> t.is(Tree.Kind.CLASSDEF));\n CallExpression call = getLastDescendant(fileInput, t -> t.is(Tree.Kind.CALL_EXPR));\n\n asser...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_32
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void test_coverage_4_4_2_multi_source() {\n settings.setProperty(PythonCoverageSensor.REPORT_PATHS_KEY, \"coverage.4.4.2-multi-sources.xml\");\n coverageSensor.execute(context);\n\n assertThat(context.lineHits(\"moduleKey:sources/folder1/file1.py\", 1)).isEqualTo(1);\n // file2....
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_153
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void IfStatement() {\n setRootRule(PythonGrammar.IF_STMT);\n IfStatement pyIfStatementTree = parse(\"if x: pass\", treeMaker::ifStatement);\n assertThat(pyIfStatementTree.keyword().value()).isEqualTo(\"if\");\n assertThat(pyIfStatementTree.condition()).isInstanceOf(Expression.cl...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "public IfStatement ifStatement(AstNode astNode) {\n Token ifToken = toPyToken(astNode.getTokens().get(0));\n AstNode condition = astNode.getFirstChild(PythonGrammar.NAMED_EXPR_TEST);\n Token colon = toPyToken(astNode.getFirstChild(PythonPunctuator.COLON).getToken());\n AstNode suite = astNode.g...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_24
{ "fields": [ { "declarator": "check = new CognitiveComplexityFunctionCheck()", "modifier": "private final", "original_string": "private final CognitiveComplexityFunctionCheck check = new CognitiveComplexityFunctionCheck();", "type": "CognitiveComplexityFunctionCheck", "var_name": "c...
{ "body": "@Test\n public void test() {\n check.setThreshold(0);\n PythonCheckVerifier.verify(\"src/test/resources/checks/cognitiveComplexityFunction.py\", check);\n }", "class_method_signature": "CognitiveComplexityFunctionCheckTest.test()", "constructor": false, "full_signature": "@Test public void te...
{ "fields": [ { "declarator": "MESSAGE = \"Refactor this function to reduce its Cognitive Complexity from %s to the %s allowed.\"", "modifier": "private static final", "original_string": "private static final String MESSAGE = \"Refactor this function to reduce its Cognitive Complexity from %s to...
{ "body": "public void setThreshold(int threshold) {\n this.threshold = threshold;\n }", "class_method_signature": "CognitiveComplexityFunctionCheck.setThreshold(int threshold)", "constructor": false, "full_signature": "public void setThreshold(int threshold)", "identifier": "setThreshold", "invocations...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_104
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void other_imported_symbol() {\n SymbolImpl xSymbol = new SymbolImpl(\"x\", \"mod.x\");\n List<Symbol> modSymbols = Collections.singletonList(xSymbol);\n Map<String, Set<Symbol>> globalSymbols = Collections.singletonMap(\"mod\", new HashSet<>(modSymbols));\n FileInput tree = par...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_73
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void funcdef() {\n assertThat(complexity(\"def f(): pass\")).isEqualTo(1);\n }", "class_method_signature": "ComplexityVisitorTest.funcdef()", "constructor": false, "full_signature": "@Test public void funcdef()", "identifier": "funcdef", "invocations": [ "isEqualTo", "...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_0
{ "fields": [], "file": "its/plugin/python-custom-rules-plugin/src/test/java/org/sonar/samples/python/CustomPythonRulesPluginTest.java", "identifier": "CustomPythonRulesPluginTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void test() {\n SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(7, 9), SonarQubeSide.SCANNER, SonarEdition.DEVELOPER);\n Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(sonarRuntime).build();\n new CustomPythonRulesPlugin().define(c...
{ "fields": [], "file": "its/plugin/python-custom-rules-plugin/src/main/java/org/sonar/samples/python/CustomPythonRulesPlugin.java", "identifier": "CustomPythonRulesPlugin", "interfaces": "implements Plugin", "methods": [ { "class_method_signature": "CustomPythonRulesPlugin.define(Context context)",...
{ "body": "@Override\n public void define(Context context) {\n context.addExtension(CustomPythonRuleRepository.class);\n }", "class_method_signature": "CustomPythonRulesPlugin.define(Context context)", "constructor": false, "full_signature": "@Override public void define(Context context)", "identifier": ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_173
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void in_expressions() {\n setRootRule(PythonGrammar.TEST);\n\n InExpression in = (InExpression) binaryExpression(\"1 in [a]\");\n assertThat(in.getKind()).isEqualTo(Tree.Kind.IN);\n assertThat(in.operator().value()).isEqualTo(\"in\");\n assertThat(in.leftOperand().getKind())....
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "private Expression binaryExpression(AstNode astNode) {\n List<AstNode> children = astNode.getChildren();\n Expression result = expression(children.get(0));\n for (int i = 1; i < astNode.getNumberOfChildren(); i += 2) {\n AstNode operator = children.get(i);\n Expression rightOperand = exp...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_53
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void parse_error() {\n inputFile(\"parse_error.py\");\n activeRules = new ActiveRulesBuilder()\n .addRule(new NewActiveRule.Builder()\n .setRuleKey(RuleKey.of(CheckList.REPOSITORY_KEY, \"ParsingError\"))\n .build())\n .build();\n\n sensor().execute(context);...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void execute(SensorContext context) {\n List<InputFile> mainFiles = getInputFiles(Type.MAIN, context);\n List<InputFile> testFiles = getInputFiles(Type.TEST, context);\n PythonScanner scanner = new PythonScanner(context, checks, fileLinesContextFactory, noSonarFilter, mainFiles...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_124
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void tokens() {\n // simple statement parsed so that we easily get all tokens from children or first token.\n FileInput parsed = parse(\"if foo:\\n pass\");\n IfStatement ifStmt = (IfStatement) parsed.statements().statements().get(0);\n List<Token> collect = new ArrayList<>(ifS...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "public static List<Token> tokens(Tree tree) {\n if (tree.is(Kind.TOKEN)) {\n return Collections.singletonList((Token) tree);\n } else if (tree.is(Kind.STRING_ELEMENT)) {\n return Collections.singletonList(tree.firstToken());\n }\n List<Token> tokens = new ArrayList<>();\n for (Tree...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_45
{ "fields": [ { "declarator": "FILE_1 = \"file1.py\"", "modifier": "private static final", "original_string": "private static final String FILE_1 = \"file1.py\";", "type": "String", "var_name": "FILE_1" }, { "declarator": "FILE_2 = \"file2.py\"", "modifier": "priv...
{ "body": "@Test\n public void sensor_descriptor() {\n activeRules = new ActiveRulesBuilder().build();\n DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();\n sensor().describe(descriptor);\n\n assertThat(descriptor.name()).isEqualTo(\"Python Sensor\");\n assertThat(descriptor.language...
{ "fields": [ { "declarator": "checks", "modifier": "private final", "original_string": "private final PythonChecks checks;", "type": "PythonChecks", "var_name": "checks" }, { "declarator": "fileLinesContextFactory", "modifier": "private final", "original_st...
{ "body": "@Override\n public void describe(SensorDescriptor descriptor) {\n descriptor\n .onlyOnLanguage(Python.KEY)\n .name(\"Python Sensor\")\n .onlyOnFileType(Type.MAIN);\n }", "class_method_signature": "PythonSensor.describe(SensorDescriptor descriptor)", "constructor": false, "full_sig...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_132
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/TreeUtilsTest.java", "identifier": "TreeUtilsTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void nonTupleParameters() {\n FileInput fileInput = PythonTestUtils.parse(\"def foo(): pass\");\n FunctionDef functionDef = PythonTestUtils.getLastDescendant(fileInput, t -> t.is(Kind.FUNCDEF));\n assertThat(TreeUtils.nonTupleParameters(functionDef)).isEmpty();\n\n fileInput = P...
{ "fields": [ { "declarator": "WHITESPACE_TOKEN_TYPES = EnumSet.of(\n PythonTokenType.NEWLINE,\n PythonTokenType.INDENT,\n PythonTokenType.DEDENT)", "modifier": "private static final", "original_string": "private static final Set<PythonTokenType> WHITESPACE_TOKEN_TYPES = EnumSet.of(\n ...
{ "body": "public static List<Parameter> nonTupleParameters(FunctionDef functionDef) {\n ParameterList parameterList = functionDef.parameters();\n if (parameterList == null) {\n return Collections.emptyList();\n }\n return parameterList.nonTuple();\n }", "class_method_signature": "TreeUtils.nonTup...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_12
{ "fields": [ { "declarator": "parser = PythonParser.create()", "modifier": "private", "original_string": "private PythonParser parser = PythonParser.create();", "type": "PythonParser", "var_name": "parser" } ], "file": "python-checks/src/test/java/org/sonar/python/checks/Exp...
{ "body": "@Test\n public void remove_parentheses() {\n assertThat(removeParentheses(exp(\"42\")).getKind()).isEqualTo(Kind.NUMERIC_LITERAL);\n assertThat(removeParentheses(exp(\"(42)\")).getKind()).isEqualTo(Kind.NUMERIC_LITERAL);\n assertThat(removeParentheses(exp(\"((42))\")).getKind()).isEqualTo(Kind.NU...
{ "fields": [ { "declarator": "ZERO_VALUES = new HashSet<>(Arrays.asList(\"0\", \"0.0\", \"0j\"))", "modifier": "private static final", "original_string": "private static final Set<String> ZERO_VALUES = new HashSet<>(Arrays.asList(\"0\", \"0.0\", \"0j\"));", "type": "Set<String>", "v...
{ "body": "public static Expression removeParentheses(@Nullable Expression expression) {\n if (expression == null) {\n return null;\n }\n Expression res = expression;\n while (res.is(Kind.PARENTHESIZED)) {\n res = ((ParenthesizedExpression) res).expression();\n }\n return res;\n }", "cl...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_165
{ "fields": [ { "declarator": "treeMaker = new PythonTreeMaker()", "modifier": "private final", "original_string": "private final PythonTreeMaker treeMaker = new PythonTreeMaker();", "type": "PythonTreeMaker", "var_name": "treeMaker" } ], "file": "python-frontend/src/test/jav...
{ "body": "@Test\n public void importFromStatement() {\n setRootRule(PythonGrammar.IMPORT_STMT);\n AstNode astNode = p.parse(\"from foo import f\");\n StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null);\n ImportFrom importStatement = (ImportFrom) treeMaker.importSta...
{ "fields": [ { "declarator": "F_STRING_PARSER = new FStringParser()", "modifier": "private static final", "original_string": "private static final FStringParser F_STRING_PARSER = new FStringParser();", "type": "FStringParser", "var_name": "F_STRING_PARSER" } ], "file": "pyth...
{ "body": "private static ImportFrom importFromStatement(AstNode astNode, Separators separators) {\n Token importKeyword = toPyToken(astNode.getFirstChild(PythonKeyword.IMPORT).getToken());\n Token fromKeyword = toPyToken(astNode.getFirstChild(PythonKeyword.FROM).getToken());\n List<Token> dottedPrefixForMod...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_86
{ "fields": [ { "declarator": "file = Mockito.mock(PythonFile.class, \"file1.py\")", "modifier": "private final", "original_string": "private final PythonFile file = Mockito.mock(PythonFile.class, \"file1.py\");", "type": "PythonFile", "var_name": "file" }, { "declarato...
{ "body": "@Test\n public void try_stmt() {\n Name x = (Name) lastExpressionInFunction(\n \"x = 1\",\n \"try:\",\n \" x = 2\",\n \"except:\",\n \" pass\",\n \"x\"\n );\n assertThat(analysis.valuesAtLocation(x)).isEmpty();\n }", "class_method_signature": "ReachingDefinition...
{ "fields": [ { "declarator": "programStateByBlock = new HashMap<>()", "modifier": "private final", "original_string": "private final Map<CfgBlock, ProgramStateAtBlock> programStateByBlock = new HashMap<>();", "type": "Map<CfgBlock, ProgramStateAtBlock>", "var_name": "programStateByB...
{ "body": "public Set<Expression> valuesAtLocation(Name variable) {\n Symbol symbol = variable.symbol();\n if (symbol == null) {\n return Collections.emptySet();\n }\n Set<Expression> assignedExpressions = assignedExpressionByName.get(variable);\n if (assignedExpressions != null) {\n // avoid...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_237
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/plugins/python/api/ParserTest.java", "identifier": "ParserTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = RecognitionException.class)\n public void parsing_error() {\n Parser parser = new Parser();\n parser.parse(\"foo(\");\n }", "class_method_signature": "ParserTest.parsing_error()", "constructor": false, "full_signature": "@Test(expected = RecognitionException.class) public voi...
{ "fields": [ { "declarator": "astParser = PythonParser.create()", "modifier": "private", "original_string": "private PythonParser astParser = PythonParser.create();", "type": "PythonParser", "var_name": "astParser" } ], "file": "python-frontend/src/main/java/org/sonar/plugin...
{ "body": "public FileInput parse(String code) {\n AstNode astNode = astParser.parse(code);\n return new PythonTreeMaker().fileInput(astNode);\n }", "class_method_signature": "Parser.parse(String code)", "constructor": false, "full_signature": "public FileInput parse(String code)", "identifier": "pars...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_69
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void pass_keyword() {\n assertThat(complexity(\"pass\")).isEqualTo(0);\n }", "class_method_signature": "ComplexityVisitorTest.pass_keyword()", "constructor": false, "full_signature": "@Test public void pass_keyword()", "identifier": "pass_keyword", "invocations": [ "isEqua...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_149
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/tree/CallExpressionImplTest.java", "identifier": "CallExpressionImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void null_callee_symbol_type() {\n assertThat(lastExpression(\"x()\").type()).isEqualTo(InferredTypes.anyType());\n }", "class_method_signature": "CallExpressionImplTest.null_callee_symbol_type()", "constructor": false, "full_signature": "@Test public void null_callee_symbol_type(...
{ "fields": [ { "declarator": "callee", "modifier": "private final", "original_string": "private final Expression callee;", "type": "Expression", "var_name": "callee" }, { "declarator": "argumentList", "modifier": "private final", "original_string": "private...
{ "body": "@Override\n public InferredType type() {\n Symbol calleeSymbol = calleeSymbol();\n if (calleeSymbol != null) {\n InferredType type = getType(calleeSymbol);\n if (type.equals(InferredTypes.anyType()) && callee.is(Kind.QUALIFIED_EXPR)) {\n return getDeclaredType(callee);\n }\n ...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_28
{ "fields": [ { "declarator": "ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\"", "modifier": "private static final", "original_string": "private static final String ABSOLUTE_PATH_PLACEHOLDER = \"{ABSOLUTE_PATH_PLACEHOLDER}\";", "type": "String", "var_name": "ABSOLUTE_PATH...
{ "body": "@Test\n public void report_not_found() {\n settings.setProperty(PythonCoverageSensor.REPORT_PATHS_KEY, \"/fake/path/report.xml\");\n\n coverageSensor.execute(context);\n\n // expected logged text: \"No report was found for sonar.python.coverage.reportPath using pattern /fake/path/report.xml\"\n ...
{ "fields": [ { "declarator": "LOG = Loggers.get(PythonCoverageSensor.class)", "modifier": "private static final", "original_string": "private static final Logger LOG = Loggers.get(PythonCoverageSensor.class);", "type": "Logger", "var_name": "LOG" }, { "declarator": "RE...
{ "body": "@Override\n public void execute(SensorContext context) {\n String baseDir = context.fileSystem().baseDir().getPath();\n Configuration config = context.config();\n\n warnDeprecatedPropertyUsage(config);\n\n HashSet<InputFile> filesCovered = new HashSet<>();\n List<File> reports = getCoverage...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_221
{ "fields": [ { "declarator": "a = new ClassSymbolImpl(\"a\", \"a\")", "modifier": "private final", "original_string": "private final ClassSymbolImpl a = new ClassSymbolImpl(\"a\", \"a\");", "type": "ClassSymbolImpl", "var_name": "a" }, { "declarator": "b = new ClassSym...
{ "body": "@Test\n public void unresolved_type_hierarchy() {\n ClassSymbolImpl x = new ClassSymbolImpl(\"x\", \"x\");\n x.setHasSuperClassWithoutSymbol();\n assertThat(new RuntimeType(x).canHaveMember(\"foo\")).isTrue();\n\n ClassSymbolImpl y = new ClassSymbolImpl(\"y\", \"y\");\n y.addSuperClass(x);\...
{ "fields": [ { "declarator": "typeClass", "modifier": "private final", "original_string": "private final ClassSymbol typeClass;", "type": "ClassSymbol", "var_name": "typeClass" }, { "declarator": "typeClassSuperClassesFQN = null", "modifier": "private", "or...
{ "body": "@Override\n public boolean canHaveMember(String memberName) {\n return typeClass.canHaveMember(memberName);\n }", "class_method_signature": "RuntimeType.canHaveMember(String memberName)", "constructor": false, "full_signature": "@Override public boolean canHaveMember(String memberName)", "iden...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_90
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ClassSymbolImplTest.java", "identifier": "ClassSymbolImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void hasUnresolvedTypeHierarchy() {\n ClassSymbolImpl a = new ClassSymbolImpl(\"x\", null);\n assertThat(a.hasUnresolvedTypeHierarchy()).isFalse();\n\n ClassSymbolImpl b = new ClassSymbolImpl(\"x\", null);\n b.addSuperClass(new ClassSymbolImpl(\"s\", null));\n assertThat(b.ha...
{ "fields": [ { "declarator": "superClasses = new ArrayList<>()", "modifier": "private final", "original_string": "private final List<Symbol> superClasses = new ArrayList<>();", "type": "List<Symbol>", "var_name": "superClasses" }, { "declarator": "allSuperClasses = nul...
{ "body": "@Override\n public boolean hasUnresolvedTypeHierarchy() {\n return hasUnresolvedTypeHierarchy(true);\n }", "class_method_signature": "ClassSymbolImpl.hasUnresolvedTypeHierarchy()", "constructor": false, "full_signature": "@Override public boolean hasUnresolvedTypeHierarchy()", "identifier": "h...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_108
{ "fields": [], "file": "python-frontend/src/test/java/org/sonar/python/semantic/ProjectLevelSymbolTableTest.java", "identifier": "ProjectLevelSymbolTableTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void metaclass_in_imported_symbol() {\n Set<Symbol> globalsMod = parse(\n new SymbolTableBuilder(\"\", pythonFile(\"mod1\")),\n \"from abc import ABCMeta\",\n \"class A(metaclass=ABCMeta): ...\"\n ).globalVariables();\n FileInput tree = parse(\n new SymbolTableB...
{ "fields": [ { "declarator": "globalSymbolsByModuleName", "modifier": "private final", "original_string": "private final Map<String, Set<Symbol>> globalSymbolsByModuleName;", "type": "Map<String, Set<Symbol>>", "var_name": "globalSymbolsByModuleName" }, { "declarator":...
{ "body": "public static ProjectLevelSymbolTable from(Map<String, Set<Symbol>> globalSymbolsByModuleName) {\n return new ProjectLevelSymbolTable(globalSymbolsByModuleName);\n }", "class_method_signature": "ProjectLevelSymbolTable.from(Map<String, Set<Symbol>> globalSymbolsByModuleName)", "constructor": false,...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...
4810329_74
{ "fields": [ { "declarator": "visitor = new ComplexityVisitor()", "modifier": "private", "original_string": "private ComplexityVisitor visitor = new ComplexityVisitor();", "type": "ComplexityVisitor", "var_name": "visitor" }, { "declarator": "parser = PythonParser.crea...
{ "body": "@Test\n public void while_statement() {\n assertThat(complexity(\"while(x): pass\")).isEqualTo(1);\n }", "class_method_signature": "ComplexityVisitorTest.while_statement()", "constructor": false, "full_signature": "@Test public void while_statement()", "identifier": "while_statement", "invoc...
{ "fields": [ { "declarator": "complexity = 0", "modifier": "private", "original_string": "private int complexity = 0;", "type": "int", "var_name": "complexity" } ], "file": "python-frontend/src/main/java/org/sonar/python/metrics/ComplexityVisitor.java", "identifier": "Comp...
{ "body": "public static int complexity(Tree pyTree) {\n ComplexityVisitor visitor = pyTree.is(Tree.Kind.FUNCDEF) ? new FunctionComplexityVisitor() : new ComplexityVisitor();\n pyTree.accept(visitor);\n return visitor.complexity;\n }", "class_method_signature": "ComplexityVisitor.complexity(Tree pyTree)",...
{ "created": "6/27/2012 3:50:36 PM +00:00", "fork": "False", "fork_count": null, "is_fork": null, "language": null, "license": "licensed", "repo_id": 4810329, "size": null, "stargazer_count": null, "stars": 138, "updates": "2020-01-27T13:20:07+00:00", "url": "https://github.com/SonarSource/sonar...