SlideShare a Scribd company logo
1 of 27
IDENTIFICATION OF BUG-PRONE API
METHODS USING CROWDSOURCED
KNOWLEDGE
Mohammad Masudur Rahman
Department of Computer Science
University of Saskatchewan, Canada
CMPT-842: Mobile and Cloud Computing
Course Instructor: Dr. Ralph Deter
AN EXAMPLE BUGGY CODE!
2
 7 API classes from 2 packages
 7 Constructors
 7 API method invocations
Fig: Zip file creation
CHALLENGES AHEAD!!
 Relevant Information Sources
 Higher Learning Curve
3
GOOD NEWS---STACK OVERFLOW!
4
4M users
10M questions 21M answers
Massive body of information
(2008)
Programming
languages
Code
example
API issues & bugs
Relevant knowledge
JAVA REFLECTION ERROR/BUG!
5
Defective code
Rectified code
Defective invocation of
API method
Corrected invocation
of API method
OUTLINE OF THE TALK
6
Stack Overflow Q & A
BRACK
Evaluation
using
8 systems
Take-home messages
Validation
with
2 studies
Exploratory study 2 Research questions
API method
invocation database
EXPLORATORY STUDY
7
Construction of API Method
Invocation Database
Answering Research
Questions
EXPLORATORY STUDY: CONSTRUCTION OF
API METHOD INVOCATION DATABASE
8
Defective
method calls
Corrected
method calls
SO Q & A
thread
Defective code
Rectified code
Island parsing
API invocation
database
SO Q&A threads Preprocessing Topic
modeling
Bug/error
related topics
Bug/error
related threads
165,580
49,425
EXPLORATORY STUDY: RESEARCH QUESTIONS
RQ1: Are programming issues, errors or exceptions
reported at Stack Overflow frequently associated with
API method invocations?
9
RQ2: Are certain APIs and their methods more prone to
programming errors or bugs than the others?
RESEARCH QUESTIONS: ANSWER TO RQ1
10
RESEARCH QUESTIONS: ANSWER TO RQ2
11Fig: Related bug-proneness of Java API packages
EXPLORATORY STUDY SUMMARY
12
Programming issues, errors or exceptions reported at
Stack Overflow frequently are associated with API
method invocations.
Some APIs and their methods more prone to
programming errors or bugs than the others?
BRACK: IDENTIFICATION OF BUG-PRONE API
METHODS USING CROWDSOURCED KNOWLEDGE
13
BRACK: API BUG-PRONENESS
HEURISTICS—H1
 API Context-Susceptibility (ACS)
14
Defective code
 Dependency an of API invocation on the context
 Context can alter the expected behaviour of the invocation
 ACS-- estimates how vulnerable an API method invocation (e.g.,
BufferedReader.readLine()) to its context
 Based on reported programming errors at Stack Overflow
BRACK: API BUG-PRONENESS
HEURISTICS—H2
 API Error-Associativity (AEA)
15 Code segments from bug related Q & A of SO.
 AEA– calculates co-occurrence of an API method invocation in
both defective and rectified code segments
Defective code
Rectified code
BRACK: API BUG-PRONENESS RANKING
16
Defective code
Island parsing
API invocations
API invocation
database
Heuristic collector
Bug-proneness
score calculator
Bug-proneness
ranking
Bug-prone
API method
invocations
 Input: Defective code
 Output: Ranked bug-prone API method invocations
 Detailed algorithm in the paper.
CODE CONTEXTUAL SIMILARITY
17
ACS, AEA,
EXPERIMENTAL DESIGN
18
8 OSS systems 3,821 Bug-fixing commits Bug reports
Island parsing
Test cases & Gold setEvaluation Validation
EXPERIMENT: RESEARCH QUESTIONS
19
RQ1: How does BRACK perform in identifying bug-prone API method
invocations from a given code segment?
RQ2: How effective are those heuristics—ACS and AEA-- in
identifying bug-prone API method invocations?
RQ3: Does BRACK show any bias to any particular subject systems
or API packages in such identification?
RQ4: Is BRACK comparable to state-of-the-art in identifying bug-
prone API method invocations from the buggy code?
Performance Metric Top-3
Top-3 Accuracy 75.93%
Mean Reciprocal Rank@3 0.47
Mean Average Precision@3 59.04%
Mean Recall@3 34.44%
PERFORMANCE: ANSWER TO RQ1
20
Fig: Performance for different Top-K
EFFECTIVENESS: ANSWER TO RQ2
21
Metric ACS (H1) AEA (H2) Combined (H1+H2)
Top-3 Accuracy 75.54% 61.77% 75.93%
MRR@3 0.47 0.44 0.47
MAP@3 58.47% 51.47% 59.04%
MR@3 33.18% 21.20% 34.44%
 ACS is found more effective than AEA
 Combination marginally improves the performance
 Detailed analysis in the paper.
BIAS: ANSWER TO RQ3
22
Metric Small Systems (4) Medium Systems (4)
Top-3 Accuracy 77.23% 74.63%
MRR@3 0.50 0.44
MAP@3 61.41% 56.65%
MR@3 34.95% 33.93%
 Small Systems <150 commits.
 Medium Systems > 400 commits.
 MWU-test on Top-3 accuracy: p-value=0.75>0.05, performance
difference is NOT significant
 Similar findings about API packages (in the paper)
STATE-OF-THE-ART
 Chen and Kim, FSE 2015
 Detects defective code in Stack Overflow and suggests
corresponding rectified code.
 Subject to the availability of code clones.
 Kim et al. FSE 2015
 Applies 28 source code metrics and 12 software
process metrics.
 Random Forest based machine learning classifier.
 Less generalization.
23
VALIDATION: ANSWER TO RQ4
24
Fig: Comparative analysis
THREATS TO VALIDITY
 Internal Validity: Replication of existing studies in
our environment.
 Best performing settings applied.
 External Validity: Generalization of BRACK.
 API invocation convention similar across various
languages.
 Construct Validity: Appropriateness of the
performance metrics.
 Metrics taken from existing literature.
 Bias in gold set: Overlapping method invocation
assumption
 JDK bug fixing history should be added.
25
TAKE HOME MESSAGES
26
THANK YOU!! QUESTIONS?
27
Masud Rahman (masud.rahman@usask.ca)
BRACK (http://www.usask.ca/~masud.rahman/brack)

More Related Content

Similar to Identifying Bug-Prone API Methods using Crowdsourced Knowledge

CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureMasud Rahman
 
Partitioned Based Regression Verification
Partitioned Based Regression VerificationPartitioned Based Regression Verification
Partitioned Based Regression VerificationAung Thu Rha Hein
 
Assisting Code Search with Automatic Query Reformulation for Bug Localization
Assisting Code Search with Automatic Query Reformulation for Bug LocalizationAssisting Code Search with Automatic Query Reformulation for Bug Localization
Assisting Code Search with Automatic Query Reformulation for Bug LocalizationBunyamin Sisman
 
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...ZhenyuWan
 
Technology for Drug Discovery Research Productivity
Technology for Drug Discovery Research ProductivityTechnology for Drug Discovery Research Productivity
Technology for Drug Discovery Research ProductivityYogesh Wagh
 
Semantic Web Technologies for Intelligent Engineering Applications
Semantic Web Technologies for  Intelligent Engineering ApplicationsSemantic Web Technologies for  Intelligent Engineering Applications
Semantic Web Technologies for Intelligent Engineering ApplicationsMarta Sabou
 
Populating a Release History Database (ICSM 2013 MIP)
Populating a Release History Database (ICSM 2013 MIP)Populating a Release History Database (ICSM 2013 MIP)
Populating a Release History Database (ICSM 2013 MIP)Martin Pinzger
 
Code-Review-COW56-Meeting
Code-Review-COW56-MeetingCode-Review-COW56-Meeting
Code-Review-COW56-MeetingMasud Rahman
 
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachAutomatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachJavier Canovas
 
A Tale of Experiments on Bug Prediction
A Tale of Experiments on Bug PredictionA Tale of Experiments on Bug Prediction
A Tale of Experiments on Bug PredictionMartin Pinzger
 
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis ViolationsAVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis ViolationsDongsun Kim
 
Predicting bugs using antipatterns
Predicting bugs using antipatternsPredicting bugs using antipatterns
Predicting bugs using antipatternsFoutse Khomh
 
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays
 
Historical and Impact Analysis of API Breaking Changes: A Large-Scale Study
Historical and Impact Analysis of API Breaking Changes: A Large-Scale StudyHistorical and Impact Analysis of API Breaking Changes: A Large-Scale Study
Historical and Impact Analysis of API Breaking Changes: A Large-Scale StudyLaerte Xavier
 
DSUS_MAO_2012_Jie
DSUS_MAO_2012_JieDSUS_MAO_2012_Jie
DSUS_MAO_2012_JieMDO_Lab
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIsSmartBear
 

Similar to Identifying Bug-Prone API Methods using Crowdsourced Knowledge (20)

CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lecture
 
Partitioned Based Regression Verification
Partitioned Based Regression VerificationPartitioned Based Regression Verification
Partitioned Based Regression Verification
 
Assisting Code Search with Automatic Query Reformulation for Bug Localization
Assisting Code Search with Automatic Query Reformulation for Bug LocalizationAssisting Code Search with Automatic Query Reformulation for Bug Localization
Assisting Code Search with Automatic Query Reformulation for Bug Localization
 
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...
Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph throug...
 
Technology for Drug Discovery Research Productivity
Technology for Drug Discovery Research ProductivityTechnology for Drug Discovery Research Productivity
Technology for Drug Discovery Research Productivity
 
Semantic Web Technologies for Intelligent Engineering Applications
Semantic Web Technologies for  Intelligent Engineering ApplicationsSemantic Web Technologies for  Intelligent Engineering Applications
Semantic Web Technologies for Intelligent Engineering Applications
 
Jr3417541760
Jr3417541760Jr3417541760
Jr3417541760
 
Populating a Release History Database (ICSM 2013 MIP)
Populating a Release History Database (ICSM 2013 MIP)Populating a Release History Database (ICSM 2013 MIP)
Populating a Release History Database (ICSM 2013 MIP)
 
Code-Review-COW56-Meeting
Code-Review-COW56-MeetingCode-Review-COW56-Meeting
Code-Review-COW56-Meeting
 
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachAutomatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
 
A Tale of Experiments on Bug Prediction
A Tale of Experiments on Bug PredictionA Tale of Experiments on Bug Prediction
A Tale of Experiments on Bug Prediction
 
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis ViolationsAVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
 
SVQdotNET: Building APIs with OpenApi
SVQdotNET: Building APIs with OpenApiSVQdotNET: Building APIs with OpenApi
SVQdotNET: Building APIs with OpenApi
 
Predicting bugs using antipatterns
Predicting bugs using antipatternsPredicting bugs using antipatterns
Predicting bugs using antipatterns
 
selenium_master.pdf
selenium_master.pdfselenium_master.pdf
selenium_master.pdf
 
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
 
STRICT-SANER2017
STRICT-SANER2017STRICT-SANER2017
STRICT-SANER2017
 
Historical and Impact Analysis of API Breaking Changes: A Large-Scale Study
Historical and Impact Analysis of API Breaking Changes: A Large-Scale StudyHistorical and Impact Analysis of API Breaking Changes: A Large-Scale Study
Historical and Impact Analysis of API Breaking Changes: A Large-Scale Study
 
DSUS_MAO_2012_Jie
DSUS_MAO_2012_JieDSUS_MAO_2012_Jie
DSUS_MAO_2012_Jie
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIs
 

More from Masud Rahman

HereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie UniversityHereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie UniversityMasud Rahman
 
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...Masud Rahman
 
PhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of SaskatchewanPhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of SaskatchewanMasud Rahman
 
PhD proposal of Masud Rahman
PhD proposal of Masud RahmanPhD proposal of Masud Rahman
PhD proposal of Masud RahmanMasud Rahman
 
PhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud RahmanPhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud RahmanMasud Rahman
 
Doctoral Symposium of Masud Rahman
Doctoral Symposium of Masud RahmanDoctoral Symposium of Masud Rahman
Doctoral Symposium of Masud RahmanMasud Rahman
 
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...Masud Rahman
 
ICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-LocalizationICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-LocalizationMasud Rahman
 
CodeInsight-SCAM2015
CodeInsight-SCAM2015CodeInsight-SCAM2015
CodeInsight-SCAM2015Masud Rahman
 
CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016Masud Rahman
 
ACER-ASE2017-slides
ACER-ASE2017-slidesACER-ASE2017-slides
ACER-ASE2017-slidesMasud Rahman
 
NLP2API: Replication package accepted by ICSME 2018
NLP2API: Replication package accepted by ICSME 2018NLP2API: Replication package accepted by ICSME 2018
NLP2API: Replication package accepted by ICSME 2018Masud Rahman
 
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...Masud Rahman
 
Improving IR-Based Bug Localization with Context-Aware-Query Reformulation
Improving IR-Based Bug Localization with Context-Aware-Query ReformulationImproving IR-Based Bug Localization with Context-Aware-Query Reformulation
Improving IR-Based Bug Localization with Context-Aware-Query ReformulationMasud Rahman
 
Exploiting Context in Dealing with Programming Errors and Exceptions
Exploiting Context in Dealing with Programming Errors and ExceptionsExploiting Context in Dealing with Programming Errors and Exceptions
Exploiting Context in Dealing with Programming Errors and ExceptionsMasud Rahman
 

More from Masud Rahman (20)

HereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie UniversityHereWeCode 2022: Dalhousie University
HereWeCode 2022: Dalhousie University
 
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
The Forgotten Role of Search Queries in IR-based Bug Localization: An Empiric...
 
PhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of SaskatchewanPhD Seminar - Masud Rahman, University of Saskatchewan
PhD Seminar - Masud Rahman, University of Saskatchewan
 
PhD proposal of Masud Rahman
PhD proposal of Masud RahmanPhD proposal of Masud Rahman
PhD proposal of Masud Rahman
 
PhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud RahmanPhD Comprehensive exam of Masud Rahman
PhD Comprehensive exam of Masud Rahman
 
Doctoral Symposium of Masud Rahman
Doctoral Symposium of Masud RahmanDoctoral Symposium of Masud Rahman
Doctoral Symposium of Masud Rahman
 
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
Supporting Source Code Search with Context-Aware and Semantics-Driven Code Se...
 
ICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-LocalizationICSE2018-Poster-Bug-Localization
ICSE2018-Poster-Bug-Localization
 
MSR2017-Challenge
MSR2017-ChallengeMSR2017-Challenge
MSR2017-Challenge
 
MSR2017-RevHelper
MSR2017-RevHelperMSR2017-RevHelper
MSR2017-RevHelper
 
MSR2015-Challenge
MSR2015-ChallengeMSR2015-Challenge
MSR2015-Challenge
 
MSR2014-Challenge
MSR2014-ChallengeMSR2014-Challenge
MSR2014-Challenge
 
CodeInsight-SCAM2015
CodeInsight-SCAM2015CodeInsight-SCAM2015
CodeInsight-SCAM2015
 
STRICT-SANER2015
STRICT-SANER2015STRICT-SANER2015
STRICT-SANER2015
 
CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016CORRECT-ToolDemo-ASE2016
CORRECT-ToolDemo-ASE2016
 
ACER-ASE2017-slides
ACER-ASE2017-slidesACER-ASE2017-slides
ACER-ASE2017-slides
 
NLP2API: Replication package accepted by ICSME 2018
NLP2API: Replication package accepted by ICSME 2018NLP2API: Replication package accepted by ICSME 2018
NLP2API: Replication package accepted by ICSME 2018
 
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...
Effective Reformulation of Query for Code Search using Crowdsourced Knowledge...
 
Improving IR-Based Bug Localization with Context-Aware-Query Reformulation
Improving IR-Based Bug Localization with Context-Aware-Query ReformulationImproving IR-Based Bug Localization with Context-Aware-Query Reformulation
Improving IR-Based Bug Localization with Context-Aware-Query Reformulation
 
Exploiting Context in Dealing with Programming Errors and Exceptions
Exploiting Context in Dealing with Programming Errors and ExceptionsExploiting Context in Dealing with Programming Errors and Exceptions
Exploiting Context in Dealing with Programming Errors and Exceptions
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

Identifying Bug-Prone API Methods using Crowdsourced Knowledge

  • 1. IDENTIFICATION OF BUG-PRONE API METHODS USING CROWDSOURCED KNOWLEDGE Mohammad Masudur Rahman Department of Computer Science University of Saskatchewan, Canada CMPT-842: Mobile and Cloud Computing Course Instructor: Dr. Ralph Deter
  • 2. AN EXAMPLE BUGGY CODE! 2  7 API classes from 2 packages  7 Constructors  7 API method invocations Fig: Zip file creation
  • 3. CHALLENGES AHEAD!!  Relevant Information Sources  Higher Learning Curve 3
  • 4. GOOD NEWS---STACK OVERFLOW! 4 4M users 10M questions 21M answers Massive body of information (2008) Programming languages Code example API issues & bugs Relevant knowledge
  • 5. JAVA REFLECTION ERROR/BUG! 5 Defective code Rectified code Defective invocation of API method Corrected invocation of API method
  • 6. OUTLINE OF THE TALK 6 Stack Overflow Q & A BRACK Evaluation using 8 systems Take-home messages Validation with 2 studies Exploratory study 2 Research questions API method invocation database
  • 7. EXPLORATORY STUDY 7 Construction of API Method Invocation Database Answering Research Questions
  • 8. EXPLORATORY STUDY: CONSTRUCTION OF API METHOD INVOCATION DATABASE 8 Defective method calls Corrected method calls SO Q & A thread Defective code Rectified code Island parsing API invocation database SO Q&A threads Preprocessing Topic modeling Bug/error related topics Bug/error related threads 165,580 49,425
  • 9. EXPLORATORY STUDY: RESEARCH QUESTIONS RQ1: Are programming issues, errors or exceptions reported at Stack Overflow frequently associated with API method invocations? 9 RQ2: Are certain APIs and their methods more prone to programming errors or bugs than the others?
  • 11. RESEARCH QUESTIONS: ANSWER TO RQ2 11Fig: Related bug-proneness of Java API packages
  • 12. EXPLORATORY STUDY SUMMARY 12 Programming issues, errors or exceptions reported at Stack Overflow frequently are associated with API method invocations. Some APIs and their methods more prone to programming errors or bugs than the others?
  • 13. BRACK: IDENTIFICATION OF BUG-PRONE API METHODS USING CROWDSOURCED KNOWLEDGE 13
  • 14. BRACK: API BUG-PRONENESS HEURISTICS—H1  API Context-Susceptibility (ACS) 14 Defective code  Dependency an of API invocation on the context  Context can alter the expected behaviour of the invocation  ACS-- estimates how vulnerable an API method invocation (e.g., BufferedReader.readLine()) to its context  Based on reported programming errors at Stack Overflow
  • 15. BRACK: API BUG-PRONENESS HEURISTICS—H2  API Error-Associativity (AEA) 15 Code segments from bug related Q & A of SO.  AEA– calculates co-occurrence of an API method invocation in both defective and rectified code segments Defective code Rectified code
  • 16. BRACK: API BUG-PRONENESS RANKING 16 Defective code Island parsing API invocations API invocation database Heuristic collector Bug-proneness score calculator Bug-proneness ranking Bug-prone API method invocations  Input: Defective code  Output: Ranked bug-prone API method invocations  Detailed algorithm in the paper.
  • 18. EXPERIMENTAL DESIGN 18 8 OSS systems 3,821 Bug-fixing commits Bug reports Island parsing Test cases & Gold setEvaluation Validation
  • 19. EXPERIMENT: RESEARCH QUESTIONS 19 RQ1: How does BRACK perform in identifying bug-prone API method invocations from a given code segment? RQ2: How effective are those heuristics—ACS and AEA-- in identifying bug-prone API method invocations? RQ3: Does BRACK show any bias to any particular subject systems or API packages in such identification? RQ4: Is BRACK comparable to state-of-the-art in identifying bug- prone API method invocations from the buggy code?
  • 20. Performance Metric Top-3 Top-3 Accuracy 75.93% Mean Reciprocal Rank@3 0.47 Mean Average Precision@3 59.04% Mean Recall@3 34.44% PERFORMANCE: ANSWER TO RQ1 20 Fig: Performance for different Top-K
  • 21. EFFECTIVENESS: ANSWER TO RQ2 21 Metric ACS (H1) AEA (H2) Combined (H1+H2) Top-3 Accuracy 75.54% 61.77% 75.93% MRR@3 0.47 0.44 0.47 MAP@3 58.47% 51.47% 59.04% MR@3 33.18% 21.20% 34.44%  ACS is found more effective than AEA  Combination marginally improves the performance  Detailed analysis in the paper.
  • 22. BIAS: ANSWER TO RQ3 22 Metric Small Systems (4) Medium Systems (4) Top-3 Accuracy 77.23% 74.63% MRR@3 0.50 0.44 MAP@3 61.41% 56.65% MR@3 34.95% 33.93%  Small Systems <150 commits.  Medium Systems > 400 commits.  MWU-test on Top-3 accuracy: p-value=0.75>0.05, performance difference is NOT significant  Similar findings about API packages (in the paper)
  • 23. STATE-OF-THE-ART  Chen and Kim, FSE 2015  Detects defective code in Stack Overflow and suggests corresponding rectified code.  Subject to the availability of code clones.  Kim et al. FSE 2015  Applies 28 source code metrics and 12 software process metrics.  Random Forest based machine learning classifier.  Less generalization. 23
  • 24. VALIDATION: ANSWER TO RQ4 24 Fig: Comparative analysis
  • 25. THREATS TO VALIDITY  Internal Validity: Replication of existing studies in our environment.  Best performing settings applied.  External Validity: Generalization of BRACK.  API invocation convention similar across various languages.  Construct Validity: Appropriateness of the performance metrics.  Metrics taken from existing literature.  Bias in gold set: Overlapping method invocation assumption  JDK bug fixing history should be added. 25
  • 27. THANK YOU!! QUESTIONS? 27 Masud Rahman (masud.rahman@usask.ca) BRACK (http://www.usask.ca/~masud.rahman/brack)

Editor's Notes

  1. Hello everyone! My name is Mohammad Masudur Rahman I am a 2nd year PhD student from University of Saskatchewan, Canada. Today, I am going to talk about an automated technique for identifying bug-prone API methods from a given buggy code.
  2. Lets take a look at this code. This code compiles, runs without any error and produces a zip file. But the only problem is the zip file is corrupted. So, the code contains a bug, that means the code is buggy. Now this code contains 7 API classes, 7 constructors and 7 method invocations. A developer’s responsibility is to debug this code line by line, check different parameter values and check for suspicious patterns. Now, a debugging context could be bigger and might involve more API invocations. Now, if there exists a tool that can predict which API invocations are more bug-prone, that could be a very helpful information for the developer during debugging. Then, the developer inspection could be little but effective. Our project actually provides such type of support to the developer.
  3. Now the task is not easy. Such prediction about API methods involves several challenges. First: lack of sufficient and reliable sources for such information -- No repository provides direct info on API method bug-proneness. --API documentation does not contain such info, they just explain the simple usages. -- Bug reports are a possible alternative source, but they might not be sufficient. Because, just from bug-report, one cannot simply determine which API methods are responsible for the bug. Second: the knowledge on API-bug proneness is a matter of long work experience. It cannot be learned over night. So, this knowledge is not trivial and it cannot be gained quickly.
  4. Good news is Stack Overflow. It’s a programming Q & A site launched in 2008. It contains a massive body of relevant information for our task. It has 4M registered users. 10 millions questions and 20M+ answers. The questions are mostly related to programming languages such as Java, C#, Javascript, PHP, Android and so on. The questions and the answers contain thousands of code examples. Most importantly, they discuss about various API issues, errors and bugs which can be mined to provide support to the developers.
  5. Now lets take a look at this buggy code example related to Java reflection API. The question shows the defective code, and invoke method is the source of the bug or error. Then, in the rectified code, that error is corrected by another developer from the community, and this is the accepted answer. Now, if we can collect such defective and rectified code segment pairs, and find that same API invocations are causing errors in various contexts, Then that suggests that target API invocation is bug-prone or prone to errors, misunderstanding or confusion.
  6. This is the outline of my today’s talk. I would first discuss our exploratory study. Then based on the findings, we propose our technique—BRACK—for bug-prone method identification. Then we discuss our experiments, evaluation and validations. And then we finally conclude with discussions.
  7. Now, this is what we do during the exploratory study. Since we are interested about API errors and bugs, we collect bug/error related questions from Stack Overflow. For that we collect 500K question titles, perform natural language preprocessing and then perform topic modeling on them using LDA. This provides a list of 200 topics from which we manually analyze and select 48 topics related to programming errors and bugs. Then we separate questions discussing those topics—we got 165K questions like that. Then in the second phase, we analyze each of those bug related questions and answers, and extract the defective and rectified code segments. We then perform island parsing on the code segments, and extract the API method invocations. Based on our observation, we conjecture that the invocations that overlap between defective and rectified code are basically connected to the bug. So, we store all the invocations from both code and develop a API invocation database.
  8. Then in the exploratory study, we ask two research questions. Are programming issues or errors related to API method invocations? --If yes, then our support will make sense. Do different API class/methods have different level of bug-proneness? --If yes, then a ranking of bug-proneness will make sense. We analyze the API invocation database to answer these research questions.
  9. Now, this is frequency distribution of the API invocations in the bug related questions. Both from probability mass function and cumulative density function, its clear that the distribution is heave-tailed. That means a small number of Q & A contain the maximum density. From the box plot, we can see a median invocation frequency of 3. More importantly, the overlapped invocation frequency between defective and rectified code is close to 2. So, yes, API invocations are pretty much associated with programming errors and bugs.
  10. Java packages contain about 3K classes in various packages, and different packages have different no. of API classes. In order to determine package level relative bug-proneness, we thus randomly choose 20 API classes from each package. Then we determine their API method invocation frequency from the database we developed. We continued this random selection and counting process 10 times, we got this statistics. This shows that API classes from different packages have different proneness to errors or bugs. In this case, we found Java IO and SQL classes have the maximum proneness to errors.
  11. So, we can summarize the findings from the exploratory study. --Programming errors/bugs are associated with API method invocations. --Some APIs and their classes are more bug-prone than others.
  12. Based on such exploratory findings, we propose our technique—BRACK– that identifies bug-prone API methods using crowdsourced knowledge.
  13. Now, we use two heuristics to capture bug-proneness of an API method invocation. For example lets look at this buggy code, this code returns a NullPointerException. Now, if you consider these two invocations, which one is likely to cause such exception? Obviously this one, right? Its because, it is too much dependent on this context– the other API invocations. We capture this concept as API Context-Susceptibility. That means how vulnerable an invocation is to the error due to their context, surrounding API invocations.
  14. Another heuristic we consider is called API error-associativity– that is how likely an invocation will be associated with error. In Stack Overflow, we saw certain API invocations in the defective code that are also repeated in the rectified code, are mostly associated with the reported error. So, this heuristic calculates such occurrences from Stack Overflow code segments.
  15. The next steps are pretty much straightforward. So, for an input buggy code, we perform island parsing, extract the API invocations and collect those two heuristics for each of the invocations. We then produce a bug-proneness score based on those heuristics as well as code contextual similarity for each invocation. Then we rank those invocations based on bug-proneness, and recommend the Top-3 invocations.
  16. Well, as said, besides heuristics, we consider code contextual similarity. When we calculate heuristics of the invocations from SO code, we also determine code similarity between input code and the defective code. Thus, our bug-proneness is based on two heuristics and the contextual similarity.
  17. Now, this is how we design our experiment. We consult with 8 OSS software systems and their bug-reports. Then we collect the bug-fixation commits and apply island parsing on the diff from the commit. This provides the experiment test case and gold set which are used for evaluation and validation.
  18. In our experiment we ask these four research questions. How does our technique perform in identifying the bug-prone API invocations in terms of traditional performance metrics? How effective are our proposed heuristics? Does it show any bias to subject systems or API packages? How does it perform compared to the state-of-the-art?
  19. Well, this is our performance. For, Top-3 recommendation, we get 76% accuracy with 59% precision which are quite promising. For example, when we check for various Top-K values, we see that accuracy and precision rise logarithmically. The recall is a bit low 35%, but, still 76% accuracy shows the promise.
  20. When we consider the heuristics, we found the Context-Susceptibility is found more effective. The second heuristic marginally improves the performance, but that actually justifies their combination in our ranking algorithm.
  21. We then divide our subject systems into two groups—small systems that have < 150 commits and the medium systems > 400 commits in our dataset. These are average performance for both groups. Interestingly, we see their performance is pretty much similar. From, the statistical tests, we also found that their performance is not significantly different. We also found similar findings for API packages. So, based on our experiments, our technique does not show bias to any subject system or API packages.
  22. Then we compare with 2 existing systems. The first one applies code clone detection on SO defective and rectified codes, and returns the rectified code as solution. -- This is limited, because, SO need to have the code clones in this case. The second study applies machine learning on source code and process metrics to determine bug-proneness of API classes.
  23. Now, this is findings. We see for each of the subject systems, our proposed technique provides quite better result, especially accuracy. The close competitor is Kim et al– the technique based on metrics and machine learning. Then when we consider the box plots, we see our performance is significantly higher than the state-of-the-art. The recall is a bit lower. But, still, the experiment demonstrates the potential of our technique.
  24. We also identifies a few threats to validity of our findings. Replication of the existing systems. We used their best settings for experiment. Generalization of our technique. The API invocation convention is pretty much similar for various languages. We did for Java language, but it can be done for other languages as well. Use of appropriate metrics– Yes, we used metrics from relevant literature such as precision and recall. So, they are appropriate. Bias in gold set: Yes, there might be some bias in gold set development, but we are working on it.
  25. So, to summarize, we propose a technique that identifies bug-prone API method invocations from a buggy code. We used defective and rectified code from SO, develop an invocation database and answer 2 research questions. Then we propose BRACK, conduct experiments using bug-fixing commits from OSS projects. Then we evaluate and validate against the state-of-the-art. All findings suggest that our technique has the potential.
  26. That’s all I have to say. Thanks for your attention. Questions?