SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Main sponsor




  Static Analysis &
AST Transformations
Hamlet D'Arcy – @HamletDRC
   Canoo Engineering AG
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       2
About Me




www.jetbrains.com/idea   3
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       4
try {
    doSomething();
} catch (UnsupportedOperationException e) {
    handleError(e);
} catch (IllegalStateException e) {
    handleError(e);
} catch (IllegalArgumentException e) {
    handleError(e);
}


  www.jetbrains.com/idea                  5
try {
    doSomething();
} catch (UnsupportedOperationException
    | IllegalStateException
    | IllegalArgumentException e) {

       handleError(e);
}



    www.jetbrains.com/idea               6
int readFirst(String path) throws Exception {

     FileReader reader = new FileReader(path);
     try {
         return reader.read();
     } finally {
         reader.close();
     }
}



    www.jetbrains.com/idea                       7
int readFirst(String path) throws Exception {

    try (FileReader reader = new FileReader(path)) {
      return reader.read();
    } finally {
      reader.close();
    }
}




     www.jetbrains.com/idea                      8
Frame makeFrame(int height, int width) {
    Frame frame = new Frame();
    frame.setSize(height, width);
    return frame;
}

Rectangle makeRectangle() {
    int x = 0;
    int y = 0;
    return new Rectangle(y, x, 20, 20);
}
   www.jetbrains.com/idea                  9
Frame makeFrame(int height, int width) {
    Frame frame = new Frame();
    frame.setSize(width, height);
    return frame;
}

Rectangle makeRectangle() {
    int x = 0;
    int y = 0;
    return new Rectangle(x, y, 20, 20);
}
   www.jetbrains.com/idea                 10
private static long count = 0L;

synchronized void increment() {
     count++;
}




  www.jetbrains.com/idea          11
private static long count = 0L;
private static Object LOCK = new Object();

void increment() {
    synchronized (LOCK) {
        count++;
    }
}



  www.jetbrains.com/idea              12
private boolean active = false;

boolean isActive() {
     return active;
}

synchronized void activate() {
     active = true;
}



www.jetbrains.com/idea            13
private boolean active = false;

synchronized boolean isActive() {
     return active;
}

synchronized void activate() {
     active = true;
}



www.jetbrains.com/idea              14
private boolean active = false;
private final ReentrantLock lock = new ReentrantLock();

boolean isActive() {
    lock.lock();
    boolean result = active;
    lock.unlock();
    return result;
}




    www.jetbrains.com/idea                         15
private boolean active = false;
private final ReentrantLock lock = new ReentrantLock();

boolean isActive() {
    lock.lock();
    try {
        return active;
    } finally {
        lock.unlock();
    }
}



    www.jetbrains.com/idea                         16
private static final boolean DEFAULT = true;

   void myMethod(Boolean value) {
       if (value == null)
           System.out.println("value: null");
           value = DEFAULT;

           System.out.println("received: " + value);
   }




   www.jetbrains.com/idea                        17
private static final boolean DEFAULT = true;

   void myMethod(Boolean value) {
       if (value == null) {
           System.out.println("value: null");
           value = DEFAULT;
       }
       System.out.println("received: " + value);
   }




   www.jetbrains.com/idea                      18
Correctness
Multi-threaded correctness
Malicious code vulnerability
Bad practice
Internationalization
Performance
Code style violations
Dodgy
                       * Bill Pugh, FindBugs
www.jetbrains.com/idea                    19
IDEA Static Analysis
Access to more than bytecode
Access to parameter names
Access to whitespace
Access to parenthesis
… and much more




www.jetbrains.com/idea         20
… and more
Suppress False Positives
Define profiles and scopes
Run on demand or one at a time
Run from command line
Team City integration
FindBugs, PMD & CheckStyle plugins
Language and framework support...


www.jetbrains.com/idea               21
Supported Frameworks
Android                  JSF
Ant                      JSP
Application Server       Junit
  Inspections            LESS
CDI(Contexts and         Maven
  Dependency             OSGi
  Injection)
                         RELAX NG
CSS
                         SCSS
Faces Model
www.jetbrains.com/idea              22
10 Best Unknown Inspections
Illegal package dependencies           return of collection or array
'this' reference escapes                  field
    constructor                        call to 'Thread.run()'
Field accessed in both                 expression.equals("literal")
    synched & unsynched                   rather than
    contexts                              "literal".equals(expression)
non private field accessed in          equals method does not check
    synched context                       class of parameter
Synchronization on 'this' and          method may be static
    'synchronized' method


http://hamletdarcy.blogspot.com/2008/04/10-best-idea-inspections-youre-not.html

www.jetbrains.com/idea                                                     23
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       24
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       25
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       26
AndroidLint
Inconsistent Arrays      Duplicate icons
Reference to an ID       Design issues like ...
  that is not in the       and (c), etc
  current layout         and many more
HashMap can be             resource issues
  replaced with
  SparseArray
Unused Resources

www.jetbrains.com/idea                        27
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       28
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       29
FindBugs vs PMD vs IDEA
IDEA has tons of inspections, quickfixes, and
  TeamCity integration
Dedicated IDEA shops don't need others
IDEA not always easy to run with build/CI
IDEA inspections aren't easy to use from
  Eclipse
FindBugs literally finds bugs. PMD is more
  best practices

www.jetbrains.com/idea                     30
QAPlug vs. Dedicated Plugins
QAPlug - Can run for Uncommitted Files
QAPlug - Nicer user interface
QAPlug gives you less control over rulesets
 and rules
Dedicated plugins are a little easier to
 share config files with




www.jetbrains.com/idea                    31
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       32
How it Works
Searches AST for Bug Patterns




www.jetbrains.com/idea          33
I shot an elephant in my pajamas.




 www.jetbrains.com/idea         34
Subject:   Verb:   Direct Object:   Indirect Object:
   I       shot     an elephant      in my pajamas
I shot an elephant in my pajamas.

How he got in my pajamas,
I'll never know.



 www.jetbrains.com/idea         36
Subject:   Verb:
                        Participle Phrase
   I       shot



                   an elephant    in my pajamas
I want to thank my parents,
            Jesus and Oprah Winfrey




www.jetbrains.com/idea                  38
I want to thank my parents,
            Jesus and Oprah Winfrey




www.jetbrains.com/idea                  39
Subject:   Verb:   Infinitive:          Participle:
   I       want     to thank


                           my parents     God     Oprah
                                                 Winfrey
I want to thank my parents,
            Jesus and Oprah Winfrey




www.jetbrains.com/idea                  41
I want to thank my parents,
             Jesus and Oprah Winfrey


God                                      Oprah
b. ?                                     b. 1954




                           You
 www.jetbrains.com/idea
                          b. 1976              42
Subject:   Verb:   Infinitive:     Participle Phrase:
   I       want     to thank          my parents



                             God                 Oprah
                                                Winfrey
www.jetbrains.com/idea   44
www.jetbrains.com/idea   45
2+3*4




www.jetbrains.com/idea           46
2+3*4

                       +
           *                 2

3                      4
    www.jetbrains.com/idea           47
2+3*4

                       +                 *
           *                 2       +       4

3                      4         2       3
    www.jetbrains.com/idea                   48
(+ 2 (* 3 4))

                       +                         *
           *                  2              +       4

3                      4             2           3
    www.jetbrains.com/idea                           49
www.jetbrains.com/idea   50
public class Person {
    private String name;

      public void setName(String name) {
          this.name = name;
      }

      public String getNameName() {
          return name;
      }

      public static void main(String[] args) {
          Person p = new Person();
          p.setName(“Hamlet”);
          System.out.println(p);
      }
}                                                51
www.jetbrains.com/idea
How it Works
Searches AST for Bug Patterns




www.jetbrains.com/idea          53
How it Works
@Override
public void visitMethod(@NotNull final PsiMethod method) {
  super.visitMethod(method);
  if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return;
  }
  if (!RecursionUtils.methodMayRecurse(method)) {
    return;
  }
  if (!RecursionUtils.methodDefinitelyRecurses(method)) {
    return;
  }
  super.registerMethodError(method);
}
   www.jetbrains.com/idea                               54
How it Works

@Override
public void visitIfStatement(GrIfStatement stmt) {
  super.visitIfStatement(stmt);
  int branches = calculateNumBranches(stmt);
  if (branches <= getLimit()) {
    return;
  }
  registerStatementError(stmt, stmt);
}

   www.jetbrains.com/idea                     55
Tree Pattern Matcher (PMD)

//FinallyStatement//ReturnStatement

//SynchronizedStatement/Block[1][count(*) = 0]

//SwitchStatement[not(SwitchLabel[@Default='true'])]



   www.jetbrains.com/idea                        56
Structural Search and Replace




www.jetbrains.com/idea          57
Write Your Own


IntelliJ IDEA Static Analysis:
Custom Rules with Structural Search & Replace

On http://JetBrains.tv



www.jetbrains.com/idea                     58
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       59
www.jetbrains.com/idea   60
www.jetbrains.com/idea   61
www.jetbrains.com/idea   62
www.jetbrains.com/idea   63
www.jetbrains.com/idea   64
www.jetbrains.com/idea   65
www.jetbrains.com/idea   66
Software Lifecycle
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0

                         … run in real-time




www.jetbrains.com/idea                    67
Software Lifecycle
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0

                          … run with build




www.jetbrains.com/idea                   68
Not Covered
@Immutable, @GuardedBy
@Pattern & @Language
@Nls, @NonNls, @PropertyKey
Duplicate Detection & Dataflow Analysis
Dependency Analysis & Dependency
 Structure Matrix

That was last year:
http://www.slideshare.net/HamletDRC/static-analysis-in-idea
www.jetbrains.com/idea                                   69
What it is
IDEA Inspections         FindBugs
PMD                      AndroidLint
CodeNarc                 Groovy 2.0
How it works
AST                      Transformations
Rewriting Code           XPath Expressions

What is possible
Lombok                   Groovy
www.jetbrains.com/idea                       70
Learn More – Q & A
My JetBrains.tv Screencasts: http://tv.jetbrains.net/tags/hamlet
My IDEA blog: http://hamletdarcy.blogspot.com/search/label/IDEA
Work's IDEA blog: http://www.canoo.com/blog/tag/idea/
Main blog: http://hamletdarcy.blogspot.com
YouTube channel: http://www.youtube.com/user/HamletDRC
Twitter: http://twitter.com/hamletdrc
IDEA RefCard from DZone: http://goo.gl/Fg4Af
IDEA Keyboard Stickers: See me

Share-a-Canooie – http://people.canoo.com/share/
Hackergarten – http://www.hackergarten.net/
     www.jetbrains.com/idea                                  71

Weitere ähnliche Inhalte

Was ist angesagt?

PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Guillaume Laforge
 
Automated Patching for Vulnerable Source Code
Automated Patching for Vulnerable Source CodeAutomated Patching for Vulnerable Source Code
Automated Patching for Vulnerable Source CodeVladimir Kochetkov
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеSergey Platonov
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
 
Visualizing MVC, and an introduction to Giotto
Visualizing MVC, and an introduction to GiottoVisualizing MVC, and an introduction to Giotto
Visualizing MVC, and an introduction to Giottopriestc
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Sergey Platonov
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementDefconRussia
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 
Much ado about randomness. What is really a random number?
Much ado about randomness. What is really a random number?Much ado about randomness. What is really a random number?
Much ado about randomness. What is really a random number?Aleksandr Yampolskiy
 
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...Christopher Frohoff
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvAnton Arhipov
 
From C++ to Objective-C
From C++ to Objective-CFrom C++ to Objective-C
From C++ to Objective-Ccorehard_by
 
New methods for exploiting ORM injections in Java applications
New methods for exploiting ORM injections in Java applicationsNew methods for exploiting ORM injections in Java applications
New methods for exploiting ORM injections in Java applicationsMikhail Egorov
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...OWASP
 

Was ist angesagt? (20)

PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 project
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
Automated Patching for Vulnerable Source Code
Automated Patching for Vulnerable Source CodeAutomated Patching for Vulnerable Source Code
Automated Patching for Vulnerable Source Code
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
 
Visualizing MVC, and an introduction to Giotto
Visualizing MVC, and an introduction to GiottoVisualizing MVC, and an introduction to Giotto
Visualizing MVC, and an introduction to Giotto
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implement
 
groovy & grails - lecture 7
groovy & grails - lecture 7groovy & grails - lecture 7
groovy & grails - lecture 7
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Much ado about randomness. What is really a random number?
Much ado about randomness. What is really a random number?Much ado about randomness. What is really a random number?
Much ado about randomness. What is really a random number?
 
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
 
Android JNI
Android JNIAndroid JNI
Android JNI
 
From C++ to Objective-C
From C++ to Objective-CFrom C++ to Objective-C
From C++ to Objective-C
 
Solid principles
Solid principlesSolid principles
Solid principles
 
New methods for exploiting ORM injections in Java applications
New methods for exploiting ORM injections in Java applicationsNew methods for exploiting ORM injections in Java applications
New methods for exploiting ORM injections in Java applications
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
Testing untestable code - IPC12
Testing untestable code - IPC12Testing untestable code - IPC12
Testing untestable code - IPC12
 
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
 

Andere mochten auch

10 Years of Groovy
10 Years of Groovy10 Years of Groovy
10 Years of GroovyHamletDRC
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - GreachHamletDRC
 
Презентация Программы лингвистического обеспечения города Сочи
Презентация Программы лингвистического обеспечения города СочиПрезентация Программы лингвистического обеспечения города Сочи
Презентация Программы лингвистического обеспечения города СочиABBYY Language Serivces
 
Is MT ready for e-Government? The Latvian Story. Indra Samite, Tilde
Is MT ready for e-Government? The Latvian Story. Indra Samite, TildeIs MT ready for e-Government? The Latvian Story. Indra Samite, Tilde
Is MT ready for e-Government? The Latvian Story. Indra Samite, TildeABBYY Language Serivces
 
Translation Automation Going Cloud: The New Landscape for Professional Transl...
Translation Automation Going Cloud: The New Landscape for Professional Transl...Translation Automation Going Cloud: The New Landscape for Professional Transl...
Translation Automation Going Cloud: The New Landscape for Professional Transl...ABBYY Language Serivces
 
33rd degree conference
33rd degree conference33rd degree conference
33rd degree conferencepcmanus
 
Castelao
CastelaoCastelao
CastelaoMarlou
 
מאבק נכי צהל
מאבק נכי צהלמאבק נכי צהל
מאבק נכי צהלguest446e83c
 
Gita Study Nov 7 Dr. Shriniwas Kashalikar
Gita Study Nov 7  Dr. Shriniwas KashalikarGita Study Nov 7  Dr. Shriniwas Kashalikar
Gita Study Nov 7 Dr. Shriniwas Kashalikarppkalghatgi
 
Trabalhos finais oa12 ut6 2010 2011
Trabalhos finais oa12 ut6 2010 2011Trabalhos finais oa12 ut6 2010 2011
Trabalhos finais oa12 ut6 2010 2011amarques_1
 
The Elements of Service-Learning
The Elements of Service-LearningThe Elements of Service-Learning
The Elements of Service-LearningChelsea Montrois
 
Holistic Health Examination Dr Shriniwas Kashalikar
Holistic Health Examination Dr Shriniwas KashalikarHolistic Health Examination Dr Shriniwas Kashalikar
Holistic Health Examination Dr Shriniwas Kashalikarppkalghatgi
 
LinkedIN Presentation - Xoriant
LinkedIN Presentation - XoriantLinkedIN Presentation - Xoriant
LinkedIN Presentation - XoriantDevisingh Balot
 
Competency Statements
Competency StatementsCompetency Statements
Competency StatementsJessica Thyer
 
ELIA - Together: The growth from freelancer to translation company - Anja Jones
ELIA - Together: The growth from freelancer to translation company - Anja JonesELIA - Together: The growth from freelancer to translation company - Anja Jones
ELIA - Together: The growth from freelancer to translation company - Anja Jonesanjajones
 

Andere mochten auch (20)

10 Years of Groovy
10 Years of Groovy10 Years of Groovy
10 Years of Groovy
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
 
Презентация Программы лингвистического обеспечения города Сочи
Презентация Программы лингвистического обеспечения города СочиПрезентация Программы лингвистического обеспечения города Сочи
Презентация Программы лингвистического обеспечения города Сочи
 
Is MT ready for e-Government? The Latvian Story. Indra Samite, Tilde
Is MT ready for e-Government? The Latvian Story. Indra Samite, TildeIs MT ready for e-Government? The Latvian Story. Indra Samite, Tilde
Is MT ready for e-Government? The Latvian Story. Indra Samite, Tilde
 
Translation Automation Going Cloud: The New Landscape for Professional Transl...
Translation Automation Going Cloud: The New Landscape for Professional Transl...Translation Automation Going Cloud: The New Landscape for Professional Transl...
Translation Automation Going Cloud: The New Landscape for Professional Transl...
 
33rd degree conference
33rd degree conference33rd degree conference
33rd degree conference
 
Vamos ubuntar
Vamos ubuntarVamos ubuntar
Vamos ubuntar
 
Castelao
CastelaoCastelao
Castelao
 
Periodismo político (1)
Periodismo político (1)Periodismo político (1)
Periodismo político (1)
 
example 5
example 5example 5
example 5
 
מאבק נכי צהל
מאבק נכי צהלמאבק נכי צהל
מאבק נכי צהל
 
Gita Study Nov 7 Dr. Shriniwas Kashalikar
Gita Study Nov 7  Dr. Shriniwas KashalikarGita Study Nov 7  Dr. Shriniwas Kashalikar
Gita Study Nov 7 Dr. Shriniwas Kashalikar
 
Task
TaskTask
Task
 
Trabalhos finais oa12 ut6 2010 2011
Trabalhos finais oa12 ut6 2010 2011Trabalhos finais oa12 ut6 2010 2011
Trabalhos finais oa12 ut6 2010 2011
 
The Elements of Service-Learning
The Elements of Service-LearningThe Elements of Service-Learning
The Elements of Service-Learning
 
Holistic Health Examination Dr Shriniwas Kashalikar
Holistic Health Examination Dr Shriniwas KashalikarHolistic Health Examination Dr Shriniwas Kashalikar
Holistic Health Examination Dr Shriniwas Kashalikar
 
LinkedIN Presentation - Xoriant
LinkedIN Presentation - XoriantLinkedIN Presentation - Xoriant
LinkedIN Presentation - Xoriant
 
Competency Statements
Competency StatementsCompetency Statements
Competency Statements
 
ELIA - Together: The growth from freelancer to translation company - Anja Jones
ELIA - Together: The growth from freelancer to translation company - Anja JonesELIA - Together: The growth from freelancer to translation company - Anja Jones
ELIA - Together: The growth from freelancer to translation company - Anja Jones
 
example 4
example 4example 4
example 4
 

Ähnlich wie Static Analysis with IDEA

Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Kuba Břečka
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Ontico
 
Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free DimensionYaser Sulaiman
 
WebApps e Frameworks Javascript
WebApps e Frameworks JavascriptWebApps e Frameworks Javascript
WebApps e Frameworks Javascriptmeet2Brains
 
Model-driven Round-trip Engineering of REST APIs
Model-driven Round-trip Engineering of REST APIsModel-driven Round-trip Engineering of REST APIs
Model-driven Round-trip Engineering of REST APIsJordi Cabot
 
Catch a spider monkey
Catch a spider monkeyCatch a spider monkey
Catch a spider monkeyChengHui Weng
 
Manipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeManipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeAndrei Ursan
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovSvetlin Nakov
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...Hafez Kamal
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 

Ähnlich wie Static Analysis with IDEA (20)

All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
 
Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free Dimension
 
WebApps e Frameworks Javascript
WebApps e Frameworks JavascriptWebApps e Frameworks Javascript
WebApps e Frameworks Javascript
 
Model-driven Round-trip Engineering of REST APIs
Model-driven Round-trip Engineering of REST APIsModel-driven Round-trip Engineering of REST APIs
Model-driven Round-trip Engineering of REST APIs
 
Catch a spider monkey
Catch a spider monkeyCatch a spider monkey
Catch a spider monkey
 
Manipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeManipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtime
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malware
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 

Mehr von HamletDRC

AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate BustersHamletDRC
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)HamletDRC
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate BustersHamletDRC
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 

Mehr von HamletDRC (6)

AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate Busters
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate Busters
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.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
 

Static Analysis with IDEA

  • 1. Main sponsor Static Analysis & AST Transformations Hamlet D'Arcy – @HamletDRC Canoo Engineering AG
  • 2. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 2
  • 4. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 4
  • 5. try { doSomething(); } catch (UnsupportedOperationException e) { handleError(e); } catch (IllegalStateException e) { handleError(e); } catch (IllegalArgumentException e) { handleError(e); } www.jetbrains.com/idea 5
  • 6. try { doSomething(); } catch (UnsupportedOperationException | IllegalStateException | IllegalArgumentException e) { handleError(e); } www.jetbrains.com/idea 6
  • 7. int readFirst(String path) throws Exception { FileReader reader = new FileReader(path); try { return reader.read(); } finally { reader.close(); } } www.jetbrains.com/idea 7
  • 8. int readFirst(String path) throws Exception { try (FileReader reader = new FileReader(path)) { return reader.read(); } finally { reader.close(); } } www.jetbrains.com/idea 8
  • 9. Frame makeFrame(int height, int width) { Frame frame = new Frame(); frame.setSize(height, width); return frame; } Rectangle makeRectangle() { int x = 0; int y = 0; return new Rectangle(y, x, 20, 20); } www.jetbrains.com/idea 9
  • 10. Frame makeFrame(int height, int width) { Frame frame = new Frame(); frame.setSize(width, height); return frame; } Rectangle makeRectangle() { int x = 0; int y = 0; return new Rectangle(x, y, 20, 20); } www.jetbrains.com/idea 10
  • 11. private static long count = 0L; synchronized void increment() { count++; } www.jetbrains.com/idea 11
  • 12. private static long count = 0L; private static Object LOCK = new Object(); void increment() { synchronized (LOCK) { count++; } } www.jetbrains.com/idea 12
  • 13. private boolean active = false; boolean isActive() { return active; } synchronized void activate() { active = true; } www.jetbrains.com/idea 13
  • 14. private boolean active = false; synchronized boolean isActive() { return active; } synchronized void activate() { active = true; } www.jetbrains.com/idea 14
  • 15. private boolean active = false; private final ReentrantLock lock = new ReentrantLock(); boolean isActive() { lock.lock(); boolean result = active; lock.unlock(); return result; } www.jetbrains.com/idea 15
  • 16. private boolean active = false; private final ReentrantLock lock = new ReentrantLock(); boolean isActive() { lock.lock(); try { return active; } finally { lock.unlock(); } } www.jetbrains.com/idea 16
  • 17. private static final boolean DEFAULT = true; void myMethod(Boolean value) { if (value == null) System.out.println("value: null"); value = DEFAULT; System.out.println("received: " + value); } www.jetbrains.com/idea 17
  • 18. private static final boolean DEFAULT = true; void myMethod(Boolean value) { if (value == null) { System.out.println("value: null"); value = DEFAULT; } System.out.println("received: " + value); } www.jetbrains.com/idea 18
  • 19. Correctness Multi-threaded correctness Malicious code vulnerability Bad practice Internationalization Performance Code style violations Dodgy * Bill Pugh, FindBugs www.jetbrains.com/idea 19
  • 20. IDEA Static Analysis Access to more than bytecode Access to parameter names Access to whitespace Access to parenthesis … and much more www.jetbrains.com/idea 20
  • 21. … and more Suppress False Positives Define profiles and scopes Run on demand or one at a time Run from command line Team City integration FindBugs, PMD & CheckStyle plugins Language and framework support... www.jetbrains.com/idea 21
  • 22. Supported Frameworks Android JSF Ant JSP Application Server Junit Inspections LESS CDI(Contexts and Maven Dependency OSGi Injection) RELAX NG CSS SCSS Faces Model www.jetbrains.com/idea 22
  • 23. 10 Best Unknown Inspections Illegal package dependencies return of collection or array 'this' reference escapes field constructor call to 'Thread.run()' Field accessed in both expression.equals("literal") synched & unsynched rather than contexts "literal".equals(expression) non private field accessed in equals method does not check synched context class of parameter Synchronization on 'this' and method may be static 'synchronized' method http://hamletdarcy.blogspot.com/2008/04/10-best-idea-inspections-youre-not.html www.jetbrains.com/idea 23
  • 24. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 24
  • 25. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 25
  • 26. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 26
  • 27. AndroidLint Inconsistent Arrays Duplicate icons Reference to an ID Design issues like ... that is not in the and (c), etc current layout and many more HashMap can be resource issues replaced with SparseArray Unused Resources www.jetbrains.com/idea 27
  • 28. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 28
  • 29. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 29
  • 30. FindBugs vs PMD vs IDEA IDEA has tons of inspections, quickfixes, and TeamCity integration Dedicated IDEA shops don't need others IDEA not always easy to run with build/CI IDEA inspections aren't easy to use from Eclipse FindBugs literally finds bugs. PMD is more best practices www.jetbrains.com/idea 30
  • 31. QAPlug vs. Dedicated Plugins QAPlug - Can run for Uncommitted Files QAPlug - Nicer user interface QAPlug gives you less control over rulesets and rules Dedicated plugins are a little easier to share config files with www.jetbrains.com/idea 31
  • 32. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 32
  • 33. How it Works Searches AST for Bug Patterns www.jetbrains.com/idea 33
  • 34. I shot an elephant in my pajamas. www.jetbrains.com/idea 34
  • 35. Subject: Verb: Direct Object: Indirect Object: I shot an elephant in my pajamas
  • 36. I shot an elephant in my pajamas. How he got in my pajamas, I'll never know. www.jetbrains.com/idea 36
  • 37. Subject: Verb: Participle Phrase I shot an elephant in my pajamas
  • 38. I want to thank my parents, Jesus and Oprah Winfrey www.jetbrains.com/idea 38
  • 39. I want to thank my parents, Jesus and Oprah Winfrey www.jetbrains.com/idea 39
  • 40. Subject: Verb: Infinitive: Participle: I want to thank my parents God Oprah Winfrey
  • 41. I want to thank my parents, Jesus and Oprah Winfrey www.jetbrains.com/idea 41
  • 42. I want to thank my parents, Jesus and Oprah Winfrey God Oprah b. ? b. 1954 You www.jetbrains.com/idea b. 1976 42
  • 43. Subject: Verb: Infinitive: Participle Phrase: I want to thank my parents God Oprah Winfrey
  • 47. 2+3*4 + * 2 3 4 www.jetbrains.com/idea 47
  • 48. 2+3*4 + * * 2 + 4 3 4 2 3 www.jetbrains.com/idea 48
  • 49. (+ 2 (* 3 4)) + * * 2 + 4 3 4 2 3 www.jetbrains.com/idea 49
  • 51. public class Person { private String name; public void setName(String name) { this.name = name; } public String getNameName() { return name; } public static void main(String[] args) { Person p = new Person(); p.setName(“Hamlet”); System.out.println(p); } } 51 www.jetbrains.com/idea
  • 52.
  • 53. How it Works Searches AST for Bug Patterns www.jetbrains.com/idea 53
  • 54. How it Works @Override public void visitMethod(@NotNull final PsiMethod method) { super.visitMethod(method); if (method.hasModifierProperty(PsiModifier.ABSTRACT)) { return; } if (!RecursionUtils.methodMayRecurse(method)) { return; } if (!RecursionUtils.methodDefinitelyRecurses(method)) { return; } super.registerMethodError(method); } www.jetbrains.com/idea 54
  • 55. How it Works @Override public void visitIfStatement(GrIfStatement stmt) { super.visitIfStatement(stmt); int branches = calculateNumBranches(stmt); if (branches <= getLimit()) { return; } registerStatementError(stmt, stmt); } www.jetbrains.com/idea 55
  • 56. Tree Pattern Matcher (PMD) //FinallyStatement//ReturnStatement //SynchronizedStatement/Block[1][count(*) = 0] //SwitchStatement[not(SwitchLabel[@Default='true'])] www.jetbrains.com/idea 56
  • 57. Structural Search and Replace www.jetbrains.com/idea 57
  • 58. Write Your Own IntelliJ IDEA Static Analysis: Custom Rules with Structural Search & Replace On http://JetBrains.tv www.jetbrains.com/idea 58
  • 59. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 59
  • 67. Software Lifecycle IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 … run in real-time www.jetbrains.com/idea 67
  • 68. Software Lifecycle IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 … run with build www.jetbrains.com/idea 68
  • 69. Not Covered @Immutable, @GuardedBy @Pattern & @Language @Nls, @NonNls, @PropertyKey Duplicate Detection & Dataflow Analysis Dependency Analysis & Dependency Structure Matrix That was last year: http://www.slideshare.net/HamletDRC/static-analysis-in-idea www.jetbrains.com/idea 69
  • 70. What it is IDEA Inspections FindBugs PMD AndroidLint CodeNarc Groovy 2.0 How it works AST Transformations Rewriting Code XPath Expressions What is possible Lombok Groovy www.jetbrains.com/idea 70
  • 71. Learn More – Q & A My JetBrains.tv Screencasts: http://tv.jetbrains.net/tags/hamlet My IDEA blog: http://hamletdarcy.blogspot.com/search/label/IDEA Work's IDEA blog: http://www.canoo.com/blog/tag/idea/ Main blog: http://hamletdarcy.blogspot.com YouTube channel: http://www.youtube.com/user/HamletDRC Twitter: http://twitter.com/hamletdrc IDEA RefCard from DZone: http://goo.gl/Fg4Af IDEA Keyboard Stickers: See me Share-a-Canooie – http://people.canoo.com/share/ Hackergarten – http://www.hackergarten.net/ www.jetbrains.com/idea 71

Hinweis der Redaktion

  1. About Me http://www.manning.com/koenig2/ http://hamletdarcy.blogspot.com Twitter: @HamletDRC Groovy, CodeNarc, JConch Committer GPars, Griffon, Gradle, etc. Contributor GroovyMag, NFJS magazine author JetBrains Academy Member
  2. - Command line &amp; CI integration - command line: need a valid .idea / .ipr file - http://www.jetbrains.com/idea/webhelp/running-inspections-offline.html - inspect.bat or inspect.sh in idea/bin - CI Integration: TeamCity has inspections built in
  3. - Mention WebStorm for other inspections